| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>pypdevsbbl.generic.io module — Python(P)DEVS-BBL documentation</title>
- <link rel="stylesheet" href="_static/nature.css" type="text/css" />
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
- <link rel="stylesheet" type="text/css" href="_static/custom.css" />
- <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
- <script type="text/javascript" src="_static/jquery.js"></script>
- <script type="text/javascript" src="_static/underscore.js"></script>
- <script type="text/javascript" src="_static/doctools.js"></script>
- <script type="text/javascript" src="_static/language_data.js"></script>
- <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
- <link rel="index" title="Index" href="genindex.html" />
- <link rel="search" title="Search" href="search.html" />
- <link rel="next" title="pypdevsbbl.generic.math module" href="pypdevsbbl.generic.math.html" />
- <link rel="prev" title="pypdevsbbl.generic.generators module" href="pypdevsbbl.generic.generators.html" />
- </head><body>
- <div class="related" role="navigation" aria-label="related navigation">
- <h3>Navigation</h3>
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="genindex.html" title="General Index"
- accesskey="I">index</a></li>
- <li class="right" >
- <a href="py-modindex.html" title="Python Module Index"
- >modules</a> |</li>
- <li class="right" >
- <a href="pypdevsbbl.generic.math.html" title="pypdevsbbl.generic.math module"
- accesskey="N">next</a> |</li>
- <li class="right" >
- <a href="pypdevsbbl.generic.generators.html" title="pypdevsbbl.generic.generators module"
- accesskey="P">previous</a> |</li>
- <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> »</li>
- <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> »</li>
- <li class="nav-item nav-item-2"><a href="pypdevsbbl.generic.html" accesskey="U">pypdevsbbl.generic package</a> »</li>
- </ul>
- </div>
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body" role="main">
-
- <div class="section" id="module-pypdevsbbl.generic.io">
- <span id="pypdevsbbl-generic-io-module"></span><h1>pypdevsbbl.generic.io module<a class="headerlink" href="#module-pypdevsbbl.generic.io" title="Permalink to this headline">¶</a></h1>
- <p>Set of PythonPDEVS I/O blocks for user interaction.</p>
- <p>The classes in this file will allow for logging values
- and messages to files for analysis and tracing.</p>
- <p>Execute this file to test the <code class="xref py py-class docutils literal notranslate"><span class="pre">Sound</span></code> block.
- You should hear a melody being played on the piano.
- If this is not the case, something is wrong with the
- audio on your system. See the block itself for more
- info.</p>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">In order to obtain the <code class="docutils literal notranslate"><span class="pre">syslog</span></code> messages, a
- <code class="docutils literal notranslate"><span class="pre">syslog</span></code> server needs to be setup. <a class="reference external" href="https://gist.github.com/marcelom/4218010">You can write
- your own server</a>
- or you can install one on your system.
- <a class="reference external" href="https://github.com/RandyParedis/PySysLogQt">PySysLogQt</a>
- is a tiny, graphical server that was made by the author
- for this specific purpose. It accepts both
- <cite>RFC 5424</cite>-formatted messages as well as the default Python
- format.</p>
- </div>
- <div class="admonition warning">
- <p class="first admonition-title">Warning</p>
- <p class="last">In order for the <a class="reference internal" href="#pypdevsbbl.generic.io.Logger" title="pypdevsbbl.generic.io.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Logger</span></code></a> block and all its
- subclasses to work, the <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> function
- needs to be called.</p>
- </div>
- <dl class="function">
- <dt id="pypdevsbbl.generic.io.setLogger">
- <code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">setLogger</code><span class="sig-paren">(</span><em>loc</em>, <em>address=('localhost'</em>, <em>1024)</em>, <em>loglevel=0</em>, <em>rfc5424=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#setLogger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.setLogger" title="Permalink to this definition">¶</a></dt>
- <dd><p>Sets the logger to a syslog logger that might follow RFC 5424.</p>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">The <code class="xref py py-meth docutils literal notranslate"><span class="pre">pypdevs.logger.setLogger()</span></code> creates a logger that’s based
- on the standard implementation of the <code class="docutils literal notranslate"><span class="pre">SysLogHandler</span></code>. Alas, this
- handler does not follow the full <cite>syslog</cite> specification as described
- in <a class="reference external" href="https://tools.ietf.org/html/rfc5424">RFC 5424</a> and therefore
- <cite>Python(P)DEVS</cite> doesn’t either. This function replaces
- <code class="xref py py-meth docutils literal notranslate"><span class="pre">pypdevs.logger.setLogger()</span></code> and provides the correct <cite>RFC</cite>.</p>
- </div>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>loc</strong> (<em>any</em>) – Location of the server, to prepend to every
- logged message.</li>
- <li><strong>address</strong> (<em>tuple</em>) – The address of the syslog server in the form of
- (ip-address, port). Defaults to <code class="docutils literal notranslate"><span class="pre">('localhost',</span> <span class="pre">1024)</span></code>.</li>
- <li><strong>loglevel</strong> (<em>numeric</em>) – Minimal log level to support. All messages with a
- lower level will be discarded. Should be one from
- in the above list. Defaults to 0.</li>
- <li><strong>rfc5424</strong> (<em>bool</em>) – Whether or not to follow <code class="docutils literal notranslate"><span class="pre">RFC</span> <span class="pre">5424</span></code> as a logging
- format. Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>. Note that this requires
- <cite>rfc5424-logging-handler</cite> to be installed.</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Logger">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Logger</code><span class="sig-paren">(</span><em>name: str</em>, <em>level: str = 'info'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Logger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Logger" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
- <p>Generic <code class="docutils literal notranslate"><span class="pre">syslog</span></code>-logger.</p>
- <p>Before this class can be used, <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> needs to be called.</p>
- <div align="center" class="align-center"><img alt="_images/logger.svg" src="_images/logger.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</li>
- <li><strong>level</strong> (<em>str</em>) – Logging level, in string format.
- This is a function that is called on the
- logger object.</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><p class="first last"><strong>input</strong> (<em>str</em>) – The message to be logged.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.Logger.extTransition">
- <code class="descname">extTransition</code><span class="sig-paren">(</span><em>inputs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Logger.extTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Logger.extTransition" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Emergency">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Emergency</code><span class="sig-paren">(</span><em>name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Emergency"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Emergency" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <a class="reference internal" href="#pypdevsbbl.generic.io.Logger" title="pypdevsbbl.generic.io.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevsbbl.generic.io.Logger</span></code></a></p>
- <p>Logs emergency messages.</p>
- <p>Before this class can be used, <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> needs to be called.</p>
- <div align="center" class="align-center"><img alt="_images/emergency.svg" src="_images/emergency.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><strong>input</strong> (<em>str</em>) – The message to be logged.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Alert">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Alert</code><span class="sig-paren">(</span><em>name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Alert"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Alert" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <a class="reference internal" href="#pypdevsbbl.generic.io.Logger" title="pypdevsbbl.generic.io.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevsbbl.generic.io.Logger</span></code></a></p>
- <p>Logs alert messages.</p>
- <p>Before this class can be used, <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> needs to be called.</p>
- <div align="center" class="align-center"><img alt="_images/alert.svg" src="_images/alert.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><strong>input</strong> (<em>str</em>) – The message to be logged.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Critical">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Critical</code><span class="sig-paren">(</span><em>name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Critical"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Critical" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <a class="reference internal" href="#pypdevsbbl.generic.io.Logger" title="pypdevsbbl.generic.io.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevsbbl.generic.io.Logger</span></code></a></p>
- <p>Logs critical messages.</p>
- <p>Before this class can be used, <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> needs to be called.</p>
- <div align="center" class="align-center"><img alt="_images/critical.svg" src="_images/critical.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><strong>input</strong> (<em>str</em>) – The message to be logged.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Error">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Error</code><span class="sig-paren">(</span><em>name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Error"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Error" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <a class="reference internal" href="#pypdevsbbl.generic.io.Logger" title="pypdevsbbl.generic.io.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevsbbl.generic.io.Logger</span></code></a></p>
- <p>Logs error messages.</p>
- <p>Before this class can be used, <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> needs to be called.</p>
- <div align="center" class="align-center"><img alt="_images/error.svg" src="_images/error.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><strong>input</strong> (<em>str</em>) – The message to be logged.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Warn">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Warn</code><span class="sig-paren">(</span><em>name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Warn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Warn" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <a class="reference internal" href="#pypdevsbbl.generic.io.Logger" title="pypdevsbbl.generic.io.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevsbbl.generic.io.Logger</span></code></a></p>
- <p>Logs warning messages.</p>
- <p>Before this class can be used, <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> needs to be called.</p>
- <div align="center" class="align-center"><img alt="_images/warn.svg" src="_images/warn.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><strong>input</strong> (<em>str</em>) – The message to be logged.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Notice">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Notice</code><span class="sig-paren">(</span><em>name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Notice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Notice" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <a class="reference internal" href="#pypdevsbbl.generic.io.Logger" title="pypdevsbbl.generic.io.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevsbbl.generic.io.Logger</span></code></a></p>
- <p>Logs notice messages.</p>
- <p>Before this class can be used, <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> needs to be called.</p>
- <div align="center" class="align-center"><img alt="_images/notice.svg" src="_images/notice.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><strong>input</strong> (<em>str</em>) – The message to be logged.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Info">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Info</code><span class="sig-paren">(</span><em>name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Info" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <a class="reference internal" href="#pypdevsbbl.generic.io.Logger" title="pypdevsbbl.generic.io.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevsbbl.generic.io.Logger</span></code></a></p>
- <p>Logs informational messages.</p>
- <p>Before this class can be used, <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> needs to be called.</p>
- <div align="center" class="align-center"><img alt="_images/info.svg" src="_images/info.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><strong>input</strong> (<em>str</em>) – The message to be logged.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Debug">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Debug</code><span class="sig-paren">(</span><em>name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Debug"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Debug" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <a class="reference internal" href="#pypdevsbbl.generic.io.Logger" title="pypdevsbbl.generic.io.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevsbbl.generic.io.Logger</span></code></a></p>
- <p>Logs debug messages.</p>
- <p>Before this class can be used, <a class="reference internal" href="#pypdevsbbl.generic.io.setLogger" title="pypdevsbbl.generic.io.setLogger"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLogger()</span></code></a> needs to be called.</p>
- <div align="center" class="align-center"><img alt="_images/debug.svg" src="_images/debug.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><strong>input</strong> (<em>str</em>) – The message to be logged.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.FileWriter">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">FileWriter</code><span class="sig-paren">(</span><em>blockname: str</em>, <em>filename: str</em>, <em>binary: bool = False</em>, <em>append: bool = True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#FileWriter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.FileWriter" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
- <p>Writes data to a file.</p>
- <div align="center" class="align-center"><img alt="_images/file-writer.svg" src="_images/file-writer.svg" /></div>
- <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>blockname</strong> (<em>str</em>) – The name of the block.</li>
- <li><strong>filename</strong> (<em>str</em>) – The name of the file to write to.</li>
- <li><strong>binary</strong> (<em>bool</em>) – Whether or not to open the file in binary mode.
- Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</li>
- <li><strong>append</strong> (<em>bool</em>) – Whether or not to append instead of overwriting.
- Note that this requires the file to already exist.
- Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>.</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><p class="first last"><strong>input</strong> (<em>str/bytes</em>) – When in binary mode, it expects a <code class="docutils literal notranslate"><span class="pre">bytes</span></code>-object,
- otherwise a <code class="docutils literal notranslate"><span class="pre">str</span></code>. This is the data that needs to be
- written to the file.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.FileWriter.extTransition">
- <code class="descname">extTransition</code><span class="sig-paren">(</span><em>inputs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#FileWriter.extTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.FileWriter.extTransition" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.FileReader">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">FileReader</code><span class="sig-paren">(</span><em>name: str</em>, <em>binary: bool = False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#FileReader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.FileReader" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
- <p>Reads contents of a file.</p>
- <p>Every time a filename arrives at the block, its contents
- will be outputted in the same time instance.</p>
- <div align="center" class="align-center"><img alt="_images/file-reader.svg" src="_images/file-reader.svg" /></div>
- <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>name</strong> (<em>str</em>) – The name of the block.</li>
- <li><strong>binary</strong> (<em>bool</em>) – Whether or not to read the file in binary mode.
- Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">State:</th><td class="field-body"><p class="first"><strong>contents</strong> (<em>str</em>) – The contents of the just-read file or <code class="docutils literal notranslate"><span class="pre">None</span></code>
- if no file has been read.</p>
- </td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Input Ports:</th><td class="field-body"><p class="first"><strong>filename</strong> (<em>str</em>) – The name of the file to read.</p>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Output Ports:</th><td class="field-body"><p class="first last"><strong>contents</strong> (<em>str/bytes</em>) – The contents of the file.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.FileReader.timeAdvance">
- <code class="descname">timeAdvance</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#FileReader.timeAdvance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.FileReader.timeAdvance" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.FileReader.intTransition">
- <code class="descname">intTransition</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#FileReader.intTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.FileReader.intTransition" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.FileReader.extTransition">
- <code class="descname">extTransition</code><span class="sig-paren">(</span><em>inputs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#FileReader.extTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.FileReader.extTransition" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.FileReader.outputFnc">
- <code class="descname">outputFnc</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#FileReader.outputFnc"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.FileReader.outputFnc" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.generic.io.Listener">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.io.</code><code class="descname">Listener</code><span class="sig-paren">(</span><em>name: str</em>, <em>dt=inf</em>, <em>fp=<function Listener.<lambda>></em>, <em>*args</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Listener"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Listener" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
- <p>Listens to an extrenal source.</p>
- <p>The provided function is executed every <code class="docutils literal notranslate"><span class="pre">dt</span></code> time and its
- return value is outputted on the <cite>polled</cite> port. Alternatively,
- every time a message arrives on the <cite>dt</cite> port, the <code class="docutils literal notranslate"><span class="pre">dt</span></code>
- value will change.</p>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">The block will poll at the beginning of the simulation.</p>
- </div>
- <div align="center" class="align-center"><img alt="_images/listener.svg" src="_images/listener.svg" /></div>
- <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>dt</strong> (<em>numeric</em>) – The delay between messages. Cannot be negative
- or zero. Defaults to <code class="docutils literal notranslate"><span class="pre">INFINITY</span></code>.</li>
- <li><strong>fp</strong> (<em>def</em>) – The polling function to be executed. Takes at least the
- current time as first input. When returning <code class="docutils literal notranslate"><span class="pre">None</span></code>,
- the <a class="reference internal" href="#pypdevsbbl.generic.io.Listener" title="pypdevsbbl.generic.io.Listener"><code class="xref py py-class docutils literal notranslate"><span class="pre">Listener</span></code></a> will not fire an output event.
- Defaults to a <cite>do nothing</cite> function: <code class="docutils literal notranslate"><span class="pre">lambda</span> <span class="pre">x:</span> <span class="pre">None</span></code>.</li>
- <li><strong>*args</strong> – Additional arguments used to call the function.</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">State:</th><td class="field-body"><ul class="first simple">
- <li><strong>dt</strong> (<em>numeric</em>) – The time between polls. Cannot be negative or zero.</li>
- <li><strong>elapsed</strong> (<em>numeric</em>) – The currently elapsed time.</li>
- <li><strong>value</strong> (<em>any</em>) – The return value.</li>
- </ul>
- </td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Input Ports:</th><td class="field-body"><p class="first"><strong>dt</strong> (<em>any</em>) – A new <code class="docutils literal notranslate"><span class="pre">dt</span></code> value.</p>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Output Ports:</th><td class="field-body"><p class="first last"><strong>listen</strong> (<em>any</em>) – The polled result.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.Listener.timeAdvance">
- <code class="descname">timeAdvance</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Listener.timeAdvance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Listener.timeAdvance" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.Listener.outputFnc">
- <code class="descname">outputFnc</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Listener.outputFnc"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Listener.outputFnc" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.Listener.intTransition">
- <code class="descname">intTransition</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Listener.intTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Listener.intTransition" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- <dl class="method">
- <dt id="pypdevsbbl.generic.io.Listener.extTransition">
- <code class="descname">extTransition</code><span class="sig-paren">(</span><em>inputs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/io.html#Listener.extTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.io.Listener.extTransition" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
- </dd></dl>
- </div>
- </div>
- </div>
- </div>
- <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
- <div class="sphinxsidebarwrapper">
- <h4>Previous topic</h4>
- <p class="topless"><a href="pypdevsbbl.generic.generators.html"
- title="previous chapter">pypdevsbbl.generic.generators module</a></p>
- <h4>Next topic</h4>
- <p class="topless"><a href="pypdevsbbl.generic.math.html"
- title="next chapter">pypdevsbbl.generic.math module</a></p>
- <div id="searchbox" style="display: none" role="search">
- <h3>Quick search</h3>
- <div class="searchformwrapper">
- <form class="search" action="search.html" method="get">
- <input type="text" name="q" />
- <input type="submit" value="Go" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
- </div>
- <script type="text/javascript">$('#searchbox').show(0);</script>
- </div>
- </div>
- <div class="clearer"></div>
- </div>
- <div class="related" role="navigation" aria-label="related navigation">
- <h3>Navigation</h3>
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="genindex.html" title="General Index"
- >index</a></li>
- <li class="right" >
- <a href="py-modindex.html" title="Python Module Index"
- >modules</a> |</li>
- <li class="right" >
- <a href="pypdevsbbl.generic.math.html" title="pypdevsbbl.generic.math module"
- >next</a> |</li>
- <li class="right" >
- <a href="pypdevsbbl.generic.generators.html" title="pypdevsbbl.generic.generators module"
- >previous</a> |</li>
- <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> »</li>
- <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> »</li>
- <li class="nav-item nav-item-2"><a href="pypdevsbbl.generic.html" >pypdevsbbl.generic package</a> »</li>
- </ul>
- </div>
- <div class="footer" role="contentinfo">
- © Copyright 2020, Randy Paredis.
- Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
- </div>
- </body>
- </html>
|