pypdevsbbl.generic.io.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>pypdevsbbl.generic.io module &#8212; Python(P)DEVS-BBL documentation</title>
  8. <link rel="stylesheet" href="_static/nature.css" type="text/css" />
  9. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  10. <link rel="stylesheet" type="text/css" href="_static/custom.css" />
  11. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  12. <script type="text/javascript" src="_static/jquery.js"></script>
  13. <script type="text/javascript" src="_static/underscore.js"></script>
  14. <script type="text/javascript" src="_static/doctools.js"></script>
  15. <script type="text/javascript" src="_static/language_data.js"></script>
  16. <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>
  17. <link rel="index" title="Index" href="genindex.html" />
  18. <link rel="search" title="Search" href="search.html" />
  19. <link rel="next" title="pypdevsbbl.generic.math module" href="pypdevsbbl.generic.math.html" />
  20. <link rel="prev" title="pypdevsbbl.generic.generators module" href="pypdevsbbl.generic.generators.html" />
  21. </head><body>
  22. <div class="related" role="navigation" aria-label="related navigation">
  23. <h3>Navigation</h3>
  24. <ul>
  25. <li class="right" style="margin-right: 10px">
  26. <a href="genindex.html" title="General Index"
  27. accesskey="I">index</a></li>
  28. <li class="right" >
  29. <a href="py-modindex.html" title="Python Module Index"
  30. >modules</a> |</li>
  31. <li class="right" >
  32. <a href="pypdevsbbl.generic.math.html" title="pypdevsbbl.generic.math module"
  33. accesskey="N">next</a> |</li>
  34. <li class="right" >
  35. <a href="pypdevsbbl.generic.generators.html" title="pypdevsbbl.generic.generators module"
  36. accesskey="P">previous</a> |</li>
  37. <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> &#187;</li>
  38. <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> &#187;</li>
  39. <li class="nav-item nav-item-2"><a href="pypdevsbbl.generic.html" accesskey="U">pypdevsbbl.generic package</a> &#187;</li>
  40. </ul>
  41. </div>
  42. <div class="document">
  43. <div class="documentwrapper">
  44. <div class="bodywrapper">
  45. <div class="body" role="main">
  46. <div class="section" id="module-pypdevsbbl.generic.io">
  47. <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>
  48. <p>Set of PythonPDEVS I/O blocks for user interaction.</p>
  49. <p>The classes in this file will allow for logging values
  50. and messages to files for analysis and tracing.</p>
  51. <p>Execute this file to test the <code class="xref py py-class docutils literal notranslate"><span class="pre">Sound</span></code> block.
  52. You should hear a melody being played on the piano.
  53. If this is not the case, something is wrong with the
  54. audio on your system. See the block itself for more
  55. info.</p>
  56. <div class="admonition note">
  57. <p class="first admonition-title">Note</p>
  58. <p class="last">In order to obtain the <code class="docutils literal notranslate"><span class="pre">syslog</span></code> messages, a
  59. <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
  60. your own server</a>
  61. or you can install one on your system.
  62. <a class="reference external" href="https://github.com/RandyParedis/PySysLogQt">PySysLogQt</a>
  63. is a tiny, graphical server that was made by the author
  64. for this specific purpose. It accepts both
  65. <cite>RFC 5424</cite>-formatted messages as well as the default Python
  66. format.</p>
  67. </div>
  68. <div class="admonition warning">
  69. <p class="first admonition-title">Warning</p>
  70. <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
  71. 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
  72. needs to be called.</p>
  73. </div>
  74. <dl class="function">
  75. <dt id="pypdevsbbl.generic.io.setLogger">
  76. <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>
  77. <dd><p>Sets the logger to a syslog logger that might follow RFC 5424.</p>
  78. <div class="admonition note">
  79. <p class="first admonition-title">Note</p>
  80. <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
  81. on the standard implementation of the <code class="docutils literal notranslate"><span class="pre">SysLogHandler</span></code>. Alas, this
  82. handler does not follow the full <cite>syslog</cite> specification as described
  83. in <a class="reference external" href="https://tools.ietf.org/html/rfc5424">RFC 5424</a> and therefore
  84. <cite>Python(P)DEVS</cite> doesn’t either. This function replaces
  85. <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>
  86. </div>
  87. <table class="docutils field-list" frame="void" rules="none">
  88. <col class="field-name" />
  89. <col class="field-body" />
  90. <tbody valign="top">
  91. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  92. <li><strong>loc</strong> (<em>any</em>) – Location of the server, to prepend to every
  93. logged message.</li>
  94. <li><strong>address</strong> (<em>tuple</em>) – The address of the syslog server in the form of
  95. (ip-address, port). Defaults to <code class="docutils literal notranslate"><span class="pre">('localhost',</span> <span class="pre">1024)</span></code>.</li>
  96. <li><strong>loglevel</strong> (<em>numeric</em>) – Minimal log level to support. All messages with a
  97. lower level will be discarded. Should be one from
  98. in the above list. Defaults to 0.</li>
  99. <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
  100. format. Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>. Note that this requires
  101. <cite>rfc5424-logging-handler</cite> to be installed.</li>
  102. </ul>
  103. </td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. </dd></dl>
  108. <dl class="class">
  109. <dt id="pypdevsbbl.generic.io.Logger">
  110. <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>
  111. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
  112. <p>Generic <code class="docutils literal notranslate"><span class="pre">syslog</span></code>-logger.</p>
  113. <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>
  114. <div align="center" class="align-center"><img alt="_images/logger.svg" src="_images/logger.svg" /></div>
  115. <table class="docutils field-list" frame="void" rules="none">
  116. <col class="field-name" />
  117. <col class="field-body" />
  118. <tbody valign="top">
  119. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  120. <li><strong>name</strong> (<em>str</em>) – The name of the block.</li>
  121. <li><strong>level</strong> (<em>str</em>) – Logging level, in string format.
  122. This is a function that is called on the
  123. logger object.</li>
  124. </ul>
  125. </td>
  126. </tr>
  127. <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>
  128. </td>
  129. </tr>
  130. </tbody>
  131. </table>
  132. <dl class="method">
  133. <dt id="pypdevsbbl.generic.io.Logger.extTransition">
  134. <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>
  135. <dd></dd></dl>
  136. </dd></dl>
  137. <dl class="class">
  138. <dt id="pypdevsbbl.generic.io.Emergency">
  139. <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>
  140. <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>
  141. <p>Logs emergency messages.</p>
  142. <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>
  143. <div align="center" class="align-center"><img alt="_images/emergency.svg" src="_images/emergency.svg" /></div>
  144. <table class="docutils field-list" frame="void" rules="none">
  145. <col class="field-name" />
  146. <col class="field-body" />
  147. <tbody valign="top">
  148. <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>
  149. </tr>
  150. <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>
  151. </tr>
  152. </tbody>
  153. </table>
  154. </dd></dl>
  155. <dl class="class">
  156. <dt id="pypdevsbbl.generic.io.Alert">
  157. <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>
  158. <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>
  159. <p>Logs alert messages.</p>
  160. <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>
  161. <div align="center" class="align-center"><img alt="_images/alert.svg" src="_images/alert.svg" /></div>
  162. <table class="docutils field-list" frame="void" rules="none">
  163. <col class="field-name" />
  164. <col class="field-body" />
  165. <tbody valign="top">
  166. <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>
  167. </tr>
  168. <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>
  169. </tr>
  170. </tbody>
  171. </table>
  172. </dd></dl>
  173. <dl class="class">
  174. <dt id="pypdevsbbl.generic.io.Critical">
  175. <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>
  176. <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>
  177. <p>Logs critical messages.</p>
  178. <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>
  179. <div align="center" class="align-center"><img alt="_images/critical.svg" src="_images/critical.svg" /></div>
  180. <table class="docutils field-list" frame="void" rules="none">
  181. <col class="field-name" />
  182. <col class="field-body" />
  183. <tbody valign="top">
  184. <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>
  185. </tr>
  186. <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>
  187. </tr>
  188. </tbody>
  189. </table>
  190. </dd></dl>
  191. <dl class="class">
  192. <dt id="pypdevsbbl.generic.io.Error">
  193. <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>
  194. <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>
  195. <p>Logs error messages.</p>
  196. <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>
  197. <div align="center" class="align-center"><img alt="_images/error.svg" src="_images/error.svg" /></div>
  198. <table class="docutils field-list" frame="void" rules="none">
  199. <col class="field-name" />
  200. <col class="field-body" />
  201. <tbody valign="top">
  202. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – The name of the block.</td>
  203. </tr>
  204. <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>
  205. </tr>
  206. </tbody>
  207. </table>
  208. </dd></dl>
  209. <dl class="class">
  210. <dt id="pypdevsbbl.generic.io.Warn">
  211. <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>
  212. <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>
  213. <p>Logs warning messages.</p>
  214. <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>
  215. <div align="center" class="align-center"><img alt="_images/warn.svg" src="_images/warn.svg" /></div>
  216. <table class="docutils field-list" frame="void" rules="none">
  217. <col class="field-name" />
  218. <col class="field-body" />
  219. <tbody valign="top">
  220. <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>
  221. </tr>
  222. <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>
  223. </tr>
  224. </tbody>
  225. </table>
  226. </dd></dl>
  227. <dl class="class">
  228. <dt id="pypdevsbbl.generic.io.Notice">
  229. <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>
  230. <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>
  231. <p>Logs notice messages.</p>
  232. <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>
  233. <div align="center" class="align-center"><img alt="_images/notice.svg" src="_images/notice.svg" /></div>
  234. <table class="docutils field-list" frame="void" rules="none">
  235. <col class="field-name" />
  236. <col class="field-body" />
  237. <tbody valign="top">
  238. <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>
  239. </tr>
  240. <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>
  241. </tr>
  242. </tbody>
  243. </table>
  244. </dd></dl>
  245. <dl class="class">
  246. <dt id="pypdevsbbl.generic.io.Info">
  247. <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>
  248. <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>
  249. <p>Logs informational messages.</p>
  250. <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>
  251. <div align="center" class="align-center"><img alt="_images/info.svg" src="_images/info.svg" /></div>
  252. <table class="docutils field-list" frame="void" rules="none">
  253. <col class="field-name" />
  254. <col class="field-body" />
  255. <tbody valign="top">
  256. <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>
  257. </tr>
  258. <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>
  259. </tr>
  260. </tbody>
  261. </table>
  262. </dd></dl>
  263. <dl class="class">
  264. <dt id="pypdevsbbl.generic.io.Debug">
  265. <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>
  266. <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>
  267. <p>Logs debug messages.</p>
  268. <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>
  269. <div align="center" class="align-center"><img alt="_images/debug.svg" src="_images/debug.svg" /></div>
  270. <table class="docutils field-list" frame="void" rules="none">
  271. <col class="field-name" />
  272. <col class="field-body" />
  273. <tbody valign="top">
  274. <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>
  275. </tr>
  276. <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>
  277. </tr>
  278. </tbody>
  279. </table>
  280. </dd></dl>
  281. <dl class="class">
  282. <dt id="pypdevsbbl.generic.io.FileWriter">
  283. <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>
  284. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
  285. <p>Writes data to a file.</p>
  286. <div align="center" class="align-center"><img alt="_images/file-writer.svg" src="_images/file-writer.svg" /></div>
  287. <table class="docutils field-list" frame="void" rules="none">
  288. <col class="field-name" />
  289. <col class="field-body" />
  290. <tbody valign="top">
  291. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  292. <li><strong>blockname</strong> (<em>str</em>) – The name of the block.</li>
  293. <li><strong>filename</strong> (<em>str</em>) – The name of the file to write to.</li>
  294. <li><strong>binary</strong> (<em>bool</em>) – Whether or not to open the file in binary mode.
  295. Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</li>
  296. <li><strong>append</strong> (<em>bool</em>) – Whether or not to append instead of overwriting.
  297. Note that this requires the file to already exist.
  298. Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>.</li>
  299. </ul>
  300. </td>
  301. </tr>
  302. <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,
  303. otherwise a <code class="docutils literal notranslate"><span class="pre">str</span></code>. This is the data that needs to be
  304. written to the file.</p>
  305. </td>
  306. </tr>
  307. </tbody>
  308. </table>
  309. <dl class="method">
  310. <dt id="pypdevsbbl.generic.io.FileWriter.extTransition">
  311. <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>
  312. <dd></dd></dl>
  313. </dd></dl>
  314. <dl class="class">
  315. <dt id="pypdevsbbl.generic.io.FileReader">
  316. <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>
  317. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
  318. <p>Reads contents of a file.</p>
  319. <p>Every time a filename arrives at the block, its contents
  320. will be outputted in the same time instance.</p>
  321. <div align="center" class="align-center"><img alt="_images/file-reader.svg" src="_images/file-reader.svg" /></div>
  322. <table class="docutils field-list" frame="void" rules="none">
  323. <col class="field-name" />
  324. <col class="field-body" />
  325. <tbody valign="top">
  326. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  327. <li><strong>name</strong> (<em>str</em>) – The name of the block.</li>
  328. <li><strong>binary</strong> (<em>bool</em>) – Whether or not to read the file in binary mode.
  329. Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</li>
  330. </ul>
  331. </td>
  332. </tr>
  333. <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>
  334. if no file has been read.</p>
  335. </td>
  336. </tr>
  337. <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>
  338. </td>
  339. </tr>
  340. <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>
  341. </td>
  342. </tr>
  343. </tbody>
  344. </table>
  345. <dl class="method">
  346. <dt id="pypdevsbbl.generic.io.FileReader.timeAdvance">
  347. <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>
  348. <dd></dd></dl>
  349. <dl class="method">
  350. <dt id="pypdevsbbl.generic.io.FileReader.intTransition">
  351. <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>
  352. <dd></dd></dl>
  353. <dl class="method">
  354. <dt id="pypdevsbbl.generic.io.FileReader.extTransition">
  355. <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>
  356. <dd></dd></dl>
  357. <dl class="method">
  358. <dt id="pypdevsbbl.generic.io.FileReader.outputFnc">
  359. <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>
  360. <dd></dd></dl>
  361. </dd></dl>
  362. <dl class="class">
  363. <dt id="pypdevsbbl.generic.io.Listener">
  364. <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=&lt;function Listener.&lt;lambda&gt;&gt;</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>
  365. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
  366. <p>Listens to an extrenal source.</p>
  367. <p>The provided function is executed every <code class="docutils literal notranslate"><span class="pre">dt</span></code> time and its
  368. return value is outputted on the <cite>polled</cite> port. Alternatively,
  369. every time a message arrives on the <cite>dt</cite> port, the <code class="docutils literal notranslate"><span class="pre">dt</span></code>
  370. value will change.</p>
  371. <div class="admonition note">
  372. <p class="first admonition-title">Note</p>
  373. <p class="last">The block will poll at the beginning of the simulation.</p>
  374. </div>
  375. <div align="center" class="align-center"><img alt="_images/listener.svg" src="_images/listener.svg" /></div>
  376. <table class="docutils field-list" frame="void" rules="none">
  377. <col class="field-name" />
  378. <col class="field-body" />
  379. <tbody valign="top">
  380. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  381. <li><strong>dt</strong> (<em>numeric</em>) – The delay between messages. Cannot be negative
  382. or zero. Defaults to <code class="docutils literal notranslate"><span class="pre">INFINITY</span></code>.</li>
  383. <li><strong>fp</strong> (<em>def</em>) – The polling function to be executed. Takes at least the
  384. current time as first input. When returning <code class="docutils literal notranslate"><span class="pre">None</span></code>,
  385. 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.
  386. 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>
  387. <li><strong>*args</strong> – Additional arguments used to call the function.</li>
  388. </ul>
  389. </td>
  390. </tr>
  391. <tr class="field-even field"><th class="field-name">State:</th><td class="field-body"><ul class="first simple">
  392. <li><strong>dt</strong> (<em>numeric</em>) – The time between polls. Cannot be negative or zero.</li>
  393. <li><strong>elapsed</strong> (<em>numeric</em>) – The currently elapsed time.</li>
  394. <li><strong>value</strong> (<em>any</em>) – The return value.</li>
  395. </ul>
  396. </td>
  397. </tr>
  398. <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>
  399. </td>
  400. </tr>
  401. <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>
  402. </td>
  403. </tr>
  404. </tbody>
  405. </table>
  406. <dl class="method">
  407. <dt id="pypdevsbbl.generic.io.Listener.timeAdvance">
  408. <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>
  409. <dd></dd></dl>
  410. <dl class="method">
  411. <dt id="pypdevsbbl.generic.io.Listener.outputFnc">
  412. <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>
  413. <dd></dd></dl>
  414. <dl class="method">
  415. <dt id="pypdevsbbl.generic.io.Listener.intTransition">
  416. <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>
  417. <dd></dd></dl>
  418. <dl class="method">
  419. <dt id="pypdevsbbl.generic.io.Listener.extTransition">
  420. <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>
  421. <dd></dd></dl>
  422. </dd></dl>
  423. </div>
  424. </div>
  425. </div>
  426. </div>
  427. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  428. <div class="sphinxsidebarwrapper">
  429. <h4>Previous topic</h4>
  430. <p class="topless"><a href="pypdevsbbl.generic.generators.html"
  431. title="previous chapter">pypdevsbbl.generic.generators module</a></p>
  432. <h4>Next topic</h4>
  433. <p class="topless"><a href="pypdevsbbl.generic.math.html"
  434. title="next chapter">pypdevsbbl.generic.math module</a></p>
  435. <div id="searchbox" style="display: none" role="search">
  436. <h3>Quick search</h3>
  437. <div class="searchformwrapper">
  438. <form class="search" action="search.html" method="get">
  439. <input type="text" name="q" />
  440. <input type="submit" value="Go" />
  441. <input type="hidden" name="check_keywords" value="yes" />
  442. <input type="hidden" name="area" value="default" />
  443. </form>
  444. </div>
  445. </div>
  446. <script type="text/javascript">$('#searchbox').show(0);</script>
  447. </div>
  448. </div>
  449. <div class="clearer"></div>
  450. </div>
  451. <div class="related" role="navigation" aria-label="related navigation">
  452. <h3>Navigation</h3>
  453. <ul>
  454. <li class="right" style="margin-right: 10px">
  455. <a href="genindex.html" title="General Index"
  456. >index</a></li>
  457. <li class="right" >
  458. <a href="py-modindex.html" title="Python Module Index"
  459. >modules</a> |</li>
  460. <li class="right" >
  461. <a href="pypdevsbbl.generic.math.html" title="pypdevsbbl.generic.math module"
  462. >next</a> |</li>
  463. <li class="right" >
  464. <a href="pypdevsbbl.generic.generators.html" title="pypdevsbbl.generic.generators module"
  465. >previous</a> |</li>
  466. <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> &#187;</li>
  467. <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> &#187;</li>
  468. <li class="nav-item nav-item-2"><a href="pypdevsbbl.generic.html" >pypdevsbbl.generic package</a> &#187;</li>
  469. </ul>
  470. </div>
  471. <div class="footer" role="contentinfo">
  472. &#169; Copyright 2020, Randy Paredis.
  473. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
  474. </div>
  475. </body>
  476. </html>