Browse Source

More name changes.

pyserial_fix
Scott Petersen 11 years ago
parent
commit
7a795ba5da
29 changed files with 240 additions and 2594 deletions
  1. BIN
      docs/_build/doctrees/environment.pickle
  2. BIN
      docs/_build/doctrees/index.doctree
  3. BIN
      docs/_build/doctrees/modules.doctree
  4. BIN
      docs/_build/doctrees/pyad2.doctree
  5. BIN
      docs/_build/doctrees/pyad2.event.doctree
  6. BIN
      docs/_build/doctrees/pyad2usb.doctree
  7. BIN
      docs/_build/doctrees/pyad2usb.event.doctree
  8. +57
    -55
      docs/_build/html/_modules/pyad2/ad2.html
  9. +40
    -40
      docs/_build/html/_modules/pyad2/devices.html
  10. +8
    -0
      docs/_build/html/_modules/pyad2/event/event.html
  11. +25
    -17
      docs/_build/html/_modules/pyad2/messages.html
  12. +3
    -4
      docs/_build/html/_modules/pyad2/util.html
  13. +9
    -10
      docs/_build/html/_modules/pyad2/zonetracking.html
  14. +1
    -1
      docs/_build/html/_sources/index.txt
  15. +0
    -19
      docs/_build/html/_sources/pyad2usb.event.txt
  16. +0
    -58
      docs/_build/html/_sources/pyad2usb.txt
  17. +21
    -21
      docs/_build/html/genindex.html
  18. BIN
      docs/_build/html/objects.inv
  19. +16
    -3
      docs/_build/html/pyad2.event.html
  20. +57
    -55
      docs/_build/html/pyad2.html
  21. +0
    -146
      docs/_build/html/pyad2usb.event.html
  22. +0
    -1277
      docs/_build/html/pyad2usb.html
  23. +1
    -1
      docs/_build/html/searchindex.js
  24. +0
    -37
      docs/_build/text/index.txt
  25. +0
    -25
      docs/_build/text/modules.txt
  26. +0
    -39
      docs/_build/text/pyad2.event.txt
  27. +0
    -784
      docs/_build/text/pyad2.txt
  28. +1
    -1
      pyad2/zonetracking.py
  29. +1
    -1
      setup.py

BIN
docs/_build/doctrees/environment.pickle View File


BIN
docs/_build/doctrees/index.doctree View File


BIN
docs/_build/doctrees/modules.doctree View File


BIN
docs/_build/doctrees/pyad2.doctree View File


BIN
docs/_build/doctrees/pyad2.event.doctree View File


BIN
docs/_build/doctrees/pyad2usb.doctree View File


BIN
docs/_build/doctrees/pyad2usb.event.doctree View File


+ 57
- 55
docs/_build/html/_modules/pyad2/ad2.html View File

@@ -48,21 +48,21 @@
<h1>Source code for pyad2.ad2</h1><div class="highlight"><pre> <h1>Source code for pyad2.ad2</h1><div class="highlight"><pre>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Provides the full AD2USB class and factory.</span>
<span class="sd">Provides the full AD2 class and factory.</span>


<span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span> <span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>


<span class="kn">import</span> <span class="nn">time</span> <span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="nn">threading</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">from</span> <span class="nn">.event</span> <span class="kn">import</span> <span class="n">event</span> <span class="kn">from</span> <span class="nn">.event</span> <span class="kn">import</span> <span class="n">event</span>
<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">devices</span>
<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">util</span>
<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">messages</span>
<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">zonetracking</span>
<span class="kn">from</span> <span class="nn">.devices</span> <span class="kn">import</span> <span class="n">USBDevice</span>
<span class="kn">from</span> <span class="nn">.util</span> <span class="kn">import</span> <span class="n">CommError</span><span class="p">,</span> <span class="n">NoDeviceError</span>
<span class="kn">from</span> <span class="nn">.messages</span> <span class="kn">import</span> <span class="n">Message</span><span class="p">,</span> <span class="n">ExpanderMessage</span><span class="p">,</span> <span class="n">RFMessage</span><span class="p">,</span> <span class="n">LRRMessage</span>
<span class="kn">from</span> <span class="nn">.zonetracking</span> <span class="kn">import</span> <span class="n">Zonetracker</span>


<div class="viewcode-block" id="Overseer"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer">[docs]</a><span class="k">class</span> <span class="nc">Overseer</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory">[docs]</a><span class="k">class</span> <span class="nc">AD2Factory</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Factory for creation of AD2USB devices as well as provides attach/detach events.&quot;</span> <span class="sd"> Factory for creation of AD2USB devices as well as provides attach/detach events.&quot;</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
@@ -74,19 +74,19 @@
<span class="n">__devices</span> <span class="o">=</span> <span class="p">[]</span> <span class="n">__devices</span> <span class="o">=</span> <span class="p">[]</span>


<span class="nd">@classmethod</span> <span class="nd">@classmethod</span>
<div class="viewcode-block" id="Overseer.find_all"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.find_all">[docs]</a> <span class="k">def</span> <span class="nf">find_all</span><span class="p">(</span><span class="n">cls</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.find_all"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.find_all">[docs]</a> <span class="k">def</span> <span class="nf">find_all</span><span class="p">(</span><span class="n">cls</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns all AD2USB devices located on the system.</span> <span class="sd"> Returns all AD2USB devices located on the system.</span>


<span class="sd"> :returns: list of devices found</span> <span class="sd"> :returns: list of devices found</span>
<span class="sd"> :raises: util.CommError</span>
<span class="sd"> :raises: CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">cls</span><span class="o">.</span><span class="n">__devices</span> <span class="o">=</span> <span class="n">devices</span><span class="o">.</span><span class="n">USBDevice</span><span class="o">.</span><span class="n">find_all</span><span class="p">()</span>
<span class="n">cls</span><span class="o">.</span><span class="n">__devices</span> <span class="o">=</span> <span class="n">USBDevice</span><span class="o">.</span><span class="n">find_all</span><span class="p">()</span>


<span class="k">return</span> <span class="n">cls</span><span class="o">.</span><span class="n">__devices</span> <span class="k">return</span> <span class="n">cls</span><span class="o">.</span><span class="n">__devices</span>
</div> </div>
<span class="nd">@classmethod</span> <span class="nd">@classmethod</span>
<div class="viewcode-block" id="Overseer.devices"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.devices">[docs]</a> <span class="k">def</span> <span class="nf">devices</span><span class="p">(</span><span class="n">cls</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.devices"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.devices">[docs]</a> <span class="k">def</span> <span class="nf">devices</span><span class="p">(</span><span class="n">cls</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns a cached list of AD2USB devices located on the system.</span> <span class="sd"> Returns a cached list of AD2USB devices located on the system.</span>


@@ -95,7 +95,7 @@
<span class="k">return</span> <span class="n">cls</span><span class="o">.</span><span class="n">__devices</span> <span class="k">return</span> <span class="n">cls</span><span class="o">.</span><span class="n">__devices</span>
</div> </div>
<span class="nd">@classmethod</span> <span class="nd">@classmethod</span>
<div class="viewcode-block" id="Overseer.create"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.create">[docs]</a> <span class="k">def</span> <span class="nf">create</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">device</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.create"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.create">[docs]</a> <span class="k">def</span> <span class="nf">create</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">device</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Factory method that returns the requested AD2USB device, or the first device.</span> <span class="sd"> Factory method that returns the requested AD2USB device, or the first device.</span>


@@ -103,18 +103,18 @@
<span class="sd"> :type device: tuple</span> <span class="sd"> :type device: tuple</span>


<span class="sd"> :returns: AD2USB object utilizing the specified device.</span> <span class="sd"> :returns: AD2USB object utilizing the specified device.</span>
<span class="sd"> :raises: util.NoDeviceError</span>
<span class="sd"> :raises: NoDeviceError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">cls</span><span class="o">.</span><span class="n">find_all</span><span class="p">()</span> <span class="n">cls</span><span class="o">.</span><span class="n">find_all</span><span class="p">()</span>


<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">cls</span><span class="o">.</span><span class="n">__devices</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">cls</span><span class="o">.</span><span class="n">__devices</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;No AD2USB devices present.&#39;</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;No AD2USB devices present.&#39;</span><span class="p">)</span>


<span class="k">if</span> <span class="n">device</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> <span class="k">if</span> <span class="n">device</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">device</span> <span class="o">=</span> <span class="n">cls</span><span class="o">.</span><span class="n">__devices</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="n">device</span> <span class="o">=</span> <span class="n">cls</span><span class="o">.</span><span class="n">__devices</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>


<span class="n">vendor</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">sernum</span><span class="p">,</span> <span class="n">ifcount</span><span class="p">,</span> <span class="n">description</span> <span class="o">=</span> <span class="n">device</span> <span class="n">vendor</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">sernum</span><span class="p">,</span> <span class="n">ifcount</span><span class="p">,</span> <span class="n">description</span> <span class="o">=</span> <span class="n">device</span>
<span class="n">device</span> <span class="o">=</span> <span class="n">devices</span><span class="o">.</span><span class="n">USBDevice</span><span class="p">((</span><span class="n">sernum</span><span class="p">,</span> <span class="n">ifcount</span> <span class="o">-</span> <span class="mi">1</span><span class="p">))</span>
<span class="n">device</span> <span class="o">=</span> <span class="n">USBDevice</span><span class="p">((</span><span class="n">sernum</span><span class="p">,</span> <span class="n">ifcount</span> <span class="o">-</span> <span class="mi">1</span><span class="p">))</span>


<span class="k">return</span> <span class="n">AD2</span><span class="p">(</span><span class="n">device</span><span class="p">)</span> <span class="k">return</span> <span class="n">AD2</span><span class="p">(</span><span class="n">device</span><span class="p">)</span>
</div> </div>
@@ -127,7 +127,7 @@
<span class="sd"> :param detached_event: Event to trigger when a device is detached.</span> <span class="sd"> :param detached_event: Event to trigger when a device is detached.</span>
<span class="sd"> :type detached_event: function</span> <span class="sd"> :type detached_event: function</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_detect_thread</span> <span class="o">=</span> <span class="n">Overseer</span><span class="o">.</span><span class="n">DetectThread</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_detect_thread</span> <span class="o">=</span> <span class="n">AD2Factory</span><span class="o">.</span><span class="n">DetectThread</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>


<span class="k">if</span> <span class="n">attached_event</span><span class="p">:</span> <span class="k">if</span> <span class="n">attached_event</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">on_attached</span> <span class="o">+=</span> <span class="n">attached_event</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_attached</span> <span class="o">+=</span> <span class="n">attached_event</span>
@@ -135,61 +135,61 @@
<span class="k">if</span> <span class="n">detached_event</span><span class="p">:</span> <span class="k">if</span> <span class="n">detached_event</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">on_detached</span> <span class="o">+=</span> <span class="n">detached_event</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_detached</span> <span class="o">+=</span> <span class="n">detached_event</span>


<span class="n">Overseer</span><span class="o">.</span><span class="n">find_all</span><span class="p">()</span>
<span class="n">AD2Factory</span><span class="o">.</span><span class="n">find_all</span><span class="p">()</span>


<span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>


<div class="viewcode-block" id="Overseer.close"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.close">[docs]</a> <span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.close"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.close">[docs]</a> <span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Clean up and shut down.</span> <span class="sd"> Clean up and shut down.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>
</div> </div>
<div class="viewcode-block" id="Overseer.start"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.start">[docs]</a> <span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.start"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.start">[docs]</a> <span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Starts the detection thread, if not already running.</span> <span class="sd"> Starts the detection thread, if not already running.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_detect_thread</span><span class="o">.</span><span class="n">is_alive</span><span class="p">():</span> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_detect_thread</span><span class="o">.</span><span class="n">is_alive</span><span class="p">():</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_detect_thread</span><span class="o">.</span><span class="n">start</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">_detect_thread</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
</div> </div>
<div class="viewcode-block" id="Overseer.stop"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.stop">[docs]</a> <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.stop"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.stop">[docs]</a> <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Stops the detection thread.</span> <span class="sd"> Stops the detection thread.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_detect_thread</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">_detect_thread</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>
</div> </div>
<div class="viewcode-block" id="Overseer.get_device"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.get_device">[docs]</a> <span class="k">def</span> <span class="nf">get_device</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">device</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.get_device"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.get_device">[docs]</a> <span class="k">def</span> <span class="nf">get_device</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">device</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Factory method that returns the requested AD2USB device, or the first device.</span> <span class="sd"> Factory method that returns the requested AD2USB device, or the first device.</span>


<span class="sd"> :param device: Tuple describing the USB device to open, as returned by find_all().</span> <span class="sd"> :param device: Tuple describing the USB device to open, as returned by find_all().</span>
<span class="sd"> :type device: tuple</span> <span class="sd"> :type device: tuple</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">Overseer</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">device</span><span class="p">)</span>
<span class="k">return</span> <span class="n">AD2Factory</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">device</span><span class="p">)</span>
</div> </div>
<div class="viewcode-block" id="Overseer.DetectThread"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.DetectThread">[docs]</a> <span class="k">class</span> <span class="nc">DetectThread</span><span class="p">(</span><span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.DetectThread"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.DetectThread">[docs]</a> <span class="k">class</span> <span class="nc">DetectThread</span><span class="p">(</span><span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Thread that handles detection of added/removed devices.</span> <span class="sd"> Thread that handles detection of added/removed devices.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">overseer</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">factory</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Constructor</span> <span class="sd"> Constructor</span>


<span class="sd"> :param overseer: Overseer object to use with the thread.</span>
<span class="sd"> :type overseer: Overseer</span>
<span class="sd"> :param factory: AD2Factory object to use with the thread.</span>
<span class="sd"> :type factory: AD2Factory</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>


<span class="bp">self</span><span class="o">.</span><span class="n">_overseer</span> <span class="o">=</span> <span class="n">overseer</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_factory</span> <span class="o">=</span> <span class="n">factory</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">False</span> <span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">False</span>


<div class="viewcode-block" id="Overseer.DetectThread.stop"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.DetectThread.stop">[docs]</a> <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.DetectThread.stop"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.DetectThread.stop">[docs]</a> <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Stops the thread.</span> <span class="sd"> Stops the thread.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">False</span> <span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">False</span>
</div> </div>
<div class="viewcode-block" id="Overseer.DetectThread.run"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.Overseer.DetectThread.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<div class="viewcode-block" id="AD2Factory.DetectThread.run"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2Factory.DetectThread.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> The actual detection process.</span> <span class="sd"> The actual detection process.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
@@ -199,20 +199,20 @@


<span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_running</span><span class="p">:</span> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_running</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span> <span class="k">try</span><span class="p">:</span>
<span class="n">Overseer</span><span class="o">.</span><span class="n">find_all</span><span class="p">()</span>
<span class="n">AD2Factory</span><span class="o">.</span><span class="n">find_all</span><span class="p">()</span>


<span class="n">current_devices</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">Overseer</span><span class="o">.</span><span class="n">devices</span><span class="p">())</span>
<span class="n">current_devices</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">AD2Factory</span><span class="o">.</span><span class="n">devices</span><span class="p">())</span>
<span class="n">new_devices</span> <span class="o">=</span> <span class="p">[</span><span class="n">d</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">current_devices</span> <span class="k">if</span> <span class="n">d</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">last_devices</span><span class="p">]</span> <span class="n">new_devices</span> <span class="o">=</span> <span class="p">[</span><span class="n">d</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">current_devices</span> <span class="k">if</span> <span class="n">d</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">last_devices</span><span class="p">]</span>
<span class="n">removed_devices</span> <span class="o">=</span> <span class="p">[</span><span class="n">d</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">last_devices</span> <span class="k">if</span> <span class="n">d</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">current_devices</span><span class="p">]</span> <span class="n">removed_devices</span> <span class="o">=</span> <span class="p">[</span><span class="n">d</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">last_devices</span> <span class="k">if</span> <span class="n">d</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">current_devices</span><span class="p">]</span>
<span class="n">last_devices</span> <span class="o">=</span> <span class="n">current_devices</span> <span class="n">last_devices</span> <span class="o">=</span> <span class="n">current_devices</span>


<span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">new_devices</span><span class="p">:</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">new_devices</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_overseer</span><span class="o">.</span><span class="n">on_attached</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_factory</span><span class="o">.</span><span class="n">on_attached</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>


<span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">removed_devices</span><span class="p">:</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">removed_devices</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_overseer</span><span class="o">.</span><span class="n">on_detached</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_factory</span><span class="o">.</span><span class="n">on_detached</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>


<span class="k">except</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">except</span> <span class="n">CommError</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">pass</span> <span class="k">pass</span>


<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.25</span><span class="p">)</span> <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.25</span><span class="p">)</span>
@@ -220,7 +220,7 @@
</div></div></div> </div></div></div>
<div class="viewcode-block" id="AD2"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2">[docs]</a><span class="k">class</span> <span class="nc">AD2</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <div class="viewcode-block" id="AD2"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2">[docs]</a><span class="k">class</span> <span class="nc">AD2</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> High-level wrapper around AD2USB/AD2SERIAL devices.</span>
<span class="sd"> High-level wrapper around AD2 devices.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>


<span class="c"># High-level Events</span> <span class="c"># High-level Events</span>
@@ -268,11 +268,11 @@
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Constructor</span> <span class="sd"> Constructor</span>


<span class="sd"> :param device: The low-level device used for this AD2USB interface.</span>
<span class="sd"> :type device: devices.Device</span>
<span class="sd"> :param device: The low-level device used for this AD2 interface.</span>
<span class="sd"> :type device: Device</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span> <span class="o">=</span> <span class="n">device</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span> <span class="o">=</span> <span class="n">device</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_zonetracker</span> <span class="o">=</span> <span class="n">zonetracking</span><span class="o">.</span><span class="n">Zonetracker</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_zonetracker</span> <span class="o">=</span> <span class="n">Zonetracker</span><span class="p">()</span>


<span class="bp">self</span><span class="o">.</span><span class="n">_power_status</span> <span class="o">=</span> <span class="bp">None</span> <span class="bp">self</span><span class="o">.</span><span class="n">_power_status</span> <span class="o">=</span> <span class="bp">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_alarm_status</span> <span class="o">=</span> <span class="bp">None</span> <span class="bp">self</span><span class="o">.</span><span class="n">_alarm_status</span> <span class="o">=</span> <span class="bp">None</span>
@@ -294,7 +294,7 @@
<span class="nd">@property</span> <span class="nd">@property</span>
<div class="viewcode-block" id="AD2.id"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.id">[docs]</a> <span class="k">def</span> <span class="nf">id</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <div class="viewcode-block" id="AD2.id"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.id">[docs]</a> <span class="k">def</span> <span class="nf">id</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> The ID of the AD2USB device.</span>
<span class="sd"> The ID of the AD2 device.</span>


<span class="sd"> :returns: The identification string for the device.</span> <span class="sd"> :returns: The identification string for the device.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
@@ -320,7 +320,9 @@
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Closes the device.</span> <span class="sd"> Closes the device.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span> <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span> <span class="o">=</span> <span class="bp">None</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span> <span class="o">=</span> <span class="bp">None</span>
</div> </div>
@@ -332,7 +334,7 @@
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Retrieves the configuration from the device.</span> <span class="sd"> Retrieves the configuration from the device.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;C</span><span class="se">\r</span><span class="s">&quot;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s">&quot;C</span><span class="se">\r</span><span class="s">&quot;</span><span class="p">)</span>
</div> </div>
<div class="viewcode-block" id="AD2.save_config"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.save_config">[docs]</a> <span class="k">def</span> <span class="nf">save_config</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <div class="viewcode-block" id="AD2.save_config"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.save_config">[docs]</a> <span class="k">def</span> <span class="nf">save_config</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -361,13 +363,13 @@


<span class="n">config_string</span> <span class="o">=</span> <span class="s">&#39;&amp;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="s">&#39;=&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">config_entries</span><span class="p">])</span> <span class="n">config_string</span> <span class="o">=</span> <span class="s">&#39;&amp;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="s">&#39;=&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">config_entries</span><span class="p">])</span>


<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;C{0}</span><span class="se">\r</span><span class="s">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">config_string</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s">&quot;C{0}</span><span class="se">\r</span><span class="s">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">config_string</span><span class="p">))</span>
</div> </div>
<div class="viewcode-block" id="AD2.reboot"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.reboot">[docs]</a> <span class="k">def</span> <span class="nf">reboot</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <div class="viewcode-block" id="AD2.reboot"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.reboot">[docs]</a> <span class="k">def</span> <span class="nf">reboot</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Reboots the device.</span> <span class="sd"> Reboots the device.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&#39;=&#39;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s">&#39;=&#39;</span><span class="p">)</span>
</div> </div>
<div class="viewcode-block" id="AD2.fault_zone"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.fault_zone">[docs]</a> <span class="k">def</span> <span class="nf">fault_zone</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zone</span><span class="p">,</span> <span class="n">simulate_wire_problem</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span> <div class="viewcode-block" id="AD2.fault_zone"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.fault_zone">[docs]</a> <span class="k">def</span> <span class="nf">fault_zone</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zone</span><span class="p">,</span> <span class="n">simulate_wire_problem</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -388,7 +390,7 @@


<span class="n">status</span> <span class="o">=</span> <span class="mi">2</span> <span class="k">if</span> <span class="n">simulate_wire_problem</span> <span class="k">else</span> <span class="mi">1</span> <span class="n">status</span> <span class="o">=</span> <span class="mi">2</span> <span class="k">if</span> <span class="n">simulate_wire_problem</span> <span class="k">else</span> <span class="mi">1</span>


<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;L{0:02}{1}</span><span class="se">\r</span><span class="s">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">zone</span><span class="p">,</span> <span class="n">status</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s">&quot;L{0:02}{1}</span><span class="se">\r</span><span class="s">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">zone</span><span class="p">,</span> <span class="n">status</span><span class="p">))</span>
</div> </div>
<div class="viewcode-block" id="AD2.clear_zone"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.clear_zone">[docs]</a> <span class="k">def</span> <span class="nf">clear_zone</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zone</span><span class="p">):</span> <div class="viewcode-block" id="AD2.clear_zone"><a class="viewcode-back" href="../../pyad2.html#pyad2.ad2.AD2.clear_zone">[docs]</a> <span class="k">def</span> <span class="nf">clear_zone</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zone</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -397,7 +399,7 @@
<span class="sd"> :param zone: The zone to clear.</span> <span class="sd"> :param zone: The zone to clear.</span>
<span class="sd"> :type zone: int</span> <span class="sd"> :type zone: int</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;L{0:02}0</span><span class="se">\r</span><span class="s">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">zone</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s">&quot;L{0:02}0</span><span class="se">\r</span><span class="s">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">zone</span><span class="p">))</span>
</div> </div>
<span class="k">def</span> <span class="nf">_wire_events</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="k">def</span> <span class="nf">_wire_events</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -420,19 +422,19 @@
<span class="sd"> :returns: An object representing the message.</span> <span class="sd"> :returns: An object representing the message.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">data</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> <span class="k">if</span> <span class="n">data</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">None</span>
<span class="k">raise</span> <span class="n">InvalidMessageError</span><span class="p">()</span>


<span class="n">msg</span> <span class="o">=</span> <span class="bp">None</span> <span class="n">msg</span> <span class="o">=</span> <span class="bp">None</span>


<span class="n">header</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">4</span><span class="p">]</span> <span class="n">header</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">4</span><span class="p">]</span>
<span class="k">if</span> <span class="n">header</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s">&#39;!&#39;</span> <span class="ow">or</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!KPE&#39;</span><span class="p">:</span> <span class="k">if</span> <span class="n">header</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s">&#39;!&#39;</span> <span class="ow">or</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!KPE&#39;</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">messages</span><span class="o">.</span><span class="n">Message</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">Message</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>


<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">address_mask</span> <span class="o">&amp;</span> <span class="n">msg</span><span class="o">.</span><span class="n">mask</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">address_mask</span> <span class="o">&amp;</span> <span class="n">msg</span><span class="o">.</span><span class="n">mask</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_update_internal_states</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_update_internal_states</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>


<span class="k">elif</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!EXP&#39;</span> <span class="ow">or</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!REL&#39;</span><span class="p">:</span> <span class="k">elif</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!EXP&#39;</span> <span class="ow">or</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!REL&#39;</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">messages</span><span class="o">.</span><span class="n">ExpanderMessage</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">ExpanderMessage</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>


<span class="bp">self</span><span class="o">.</span><span class="n">_update_internal_states</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_update_internal_states</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>


@@ -451,7 +453,7 @@
<span class="k">return</span> <span class="n">msg</span> <span class="k">return</span> <span class="n">msg</span>


<span class="k">def</span> <span class="nf">_handle_rfx</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span> <span class="k">def</span> <span class="nf">_handle_rfx</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">messages</span><span class="o">.</span><span class="n">RFMessage</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">RFMessage</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>


<span class="bp">self</span><span class="o">.</span><span class="n">on_rfx_message</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_rfx_message</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>


@@ -466,7 +468,7 @@


<span class="sd"> :returns: An object representing the LRR message.</span> <span class="sd"> :returns: An object representing the LRR message.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">messages</span><span class="o">.</span><span class="n">LRRMessage</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">LRRMessage</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>


<span class="k">if</span> <span class="n">msg</span><span class="o">.</span><span class="n">event_type</span> <span class="o">==</span> <span class="s">&#39;ALARM_PANIC&#39;</span><span class="p">:</span> <span class="k">if</span> <span class="n">msg</span><span class="o">.</span><span class="n">event_type</span> <span class="o">==</span> <span class="s">&#39;ALARM_PANIC&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_panic_status</span> <span class="o">=</span> <span class="bp">True</span> <span class="bp">self</span><span class="o">.</span><span class="n">_panic_status</span> <span class="o">=</span> <span class="bp">True</span>
@@ -518,7 +520,7 @@
<span class="sd"> :param message: Message to update internal states with.</span> <span class="sd"> :param message: Message to update internal states with.</span>
<span class="sd"> :type message: Message, ExpanderMessage, LRRMessage, or RFMessage</span> <span class="sd"> :type message: Message, ExpanderMessage, LRRMessage, or RFMessage</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">messages</span><span class="o">.</span><span class="n">Message</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">Message</span><span class="p">):</span>
<span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">ac_power</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_power_status</span><span class="p">:</span> <span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">ac_power</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_power_status</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_power_status</span><span class="p">,</span> <span class="n">old_status</span> <span class="o">=</span> <span class="n">message</span><span class="o">.</span><span class="n">ac_power</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_power_status</span> <span class="bp">self</span><span class="o">.</span><span class="n">_power_status</span><span class="p">,</span> <span class="n">old_status</span> <span class="o">=</span> <span class="n">message</span><span class="o">.</span><span class="n">ac_power</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_power_status</span>


@@ -560,8 +562,8 @@
<span class="bp">self</span><span class="o">.</span><span class="n">_fire_status</span> <span class="o">=</span> <span class="p">(</span><span class="n">message</span><span class="o">.</span><span class="n">fire_alarm</span><span class="p">,</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">())</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fire_status</span> <span class="o">=</span> <span class="p">(</span><span class="n">message</span><span class="o">.</span><span class="n">fire_alarm</span><span class="p">,</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">on_fire</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fire_status</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_fire</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fire_status</span><span class="p">)</span>


<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">messages</span><span class="o">.</span><span class="n">ExpanderMessage</span><span class="p">):</span>
<span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">messages</span><span class="o">.</span><span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">RELAY</span><span class="p">:</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">ExpanderMessage</span><span class="p">):</span>
<span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">RELAY</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_relay_status</span><span class="p">[(</span><span class="n">message</span><span class="o">.</span><span class="n">address</span><span class="p">,</span> <span class="n">message</span><span class="o">.</span><span class="n">channel</span><span class="p">)]</span> <span class="o">=</span> <span class="n">message</span><span class="o">.</span><span class="n">value</span> <span class="bp">self</span><span class="o">.</span><span class="n">_relay_status</span><span class="p">[(</span><span class="n">message</span><span class="o">.</span><span class="n">address</span><span class="p">,</span> <span class="n">message</span><span class="o">.</span><span class="n">channel</span><span class="p">)]</span> <span class="o">=</span> <span class="n">message</span><span class="o">.</span><span class="n">value</span>


<span class="bp">self</span><span class="o">.</span><span class="n">on_relay_changed</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_relay_changed</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
@@ -578,9 +580,9 @@


<span class="c"># Retrieve a list of faults.</span> <span class="c"># Retrieve a list of faults.</span>
<span class="c"># NOTE: This only happens on first boot or after exiting programming mode.</span> <span class="c"># NOTE: This only happens on first boot or after exiting programming mode.</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">messages</span><span class="o">.</span><span class="n">Message</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">Message</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">message</span><span class="o">.</span><span class="n">ready</span> <span class="ow">and</span> <span class="s">&quot;Hit * for faults&quot;</span> <span class="ow">in</span> <span class="n">message</span><span class="o">.</span><span class="n">text</span><span class="p">:</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">message</span><span class="o">.</span><span class="n">ready</span> <span class="ow">and</span> <span class="s">&quot;Hit * for faults&quot;</span> <span class="ow">in</span> <span class="n">message</span><span class="o">.</span><span class="n">text</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&#39;*&#39;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s">&#39;*&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="k">return</span>


<span class="bp">self</span><span class="o">.</span><span class="n">_zonetracker</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_zonetracker</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>


+ 40
- 40
docs/_build/html/_modules/pyad2/devices.html View File

@@ -48,7 +48,7 @@
<h1>Source code for pyad2.devices</h1><div class="highlight"><pre> <h1>Source code for pyad2.devices</h1><div class="highlight"><pre>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Contains different types of devices belonging to the AD2USB family.</span>
<span class="sd">Contains different types of devices belonging to the AD2 family.</span>


<span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span> <span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -58,15 +58,16 @@
<span class="kn">import</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="nn">threading</span>
<span class="kn">import</span> <span class="nn">serial</span><span class="o">,</span> <span class="nn">serial.tools.list_ports</span> <span class="kn">import</span> <span class="nn">serial</span><span class="o">,</span> <span class="nn">serial.tools.list_ports</span>
<span class="kn">import</span> <span class="nn">socket</span> <span class="kn">import</span> <span class="nn">socket</span>

<span class="kn">from</span> <span class="nn">OpenSSL</span> <span class="kn">import</span> <span class="n">SSL</span><span class="p">,</span> <span class="n">crypto</span> <span class="kn">from</span> <span class="nn">OpenSSL</span> <span class="kn">import</span> <span class="n">SSL</span><span class="p">,</span> <span class="n">crypto</span>
<span class="kn">from</span> <span class="nn">pyftdi.pyftdi.ftdi</span> <span class="kn">import</span> <span class="o">*</span> <span class="kn">from</span> <span class="nn">pyftdi.pyftdi.ftdi</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">pyftdi.pyftdi.usbtools</span> <span class="kn">import</span> <span class="o">*</span> <span class="kn">from</span> <span class="nn">pyftdi.pyftdi.usbtools</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">util</span>
<span class="kn">from</span> <span class="nn">.util</span> <span class="kn">import</span> <span class="n">CommError</span><span class="p">,</span> <span class="n">TimeoutError</span><span class="p">,</span> <span class="n">NoDeviceError</span>
<span class="kn">from</span> <span class="nn">.event</span> <span class="kn">import</span> <span class="n">event</span> <span class="kn">from</span> <span class="nn">.event</span> <span class="kn">import</span> <span class="n">event</span>


<div class="viewcode-block" id="Device"><a class="viewcode-back" href="../../pyad2.html#pyad2.devices.Device">[docs]</a><span class="k">class</span> <span class="nc">Device</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <div class="viewcode-block" id="Device"><a class="viewcode-back" href="../../pyad2.html#pyad2.devices.Device">[docs]</a><span class="k">class</span> <span class="nc">Device</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Generic parent device to all AD2USB products.</span>
<span class="sd"> Generic parent device to all AD2 products.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>


<span class="c"># Generic device events</span> <span class="c"># Generic device events</span>
@@ -167,7 +168,7 @@
<span class="k">try</span><span class="p">:</span> <span class="k">try</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">read_line</span><span class="p">(</span><span class="n">timeout</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">READ_TIMEOUT</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">read_line</span><span class="p">(</span><span class="n">timeout</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">READ_TIMEOUT</span><span class="p">)</span>


<span class="k">except</span> <span class="n">util</span><span class="o">.</span><span class="n">TimeoutError</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">except</span> <span class="n">TimeoutError</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">pass</span> <span class="k">pass</span>


<span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
@@ -196,7 +197,7 @@
<span class="sd"> Returns all FTDI devices matching our vendor and product IDs.</span> <span class="sd"> Returns all FTDI devices matching our vendor and product IDs.</span>


<span class="sd"> :returns: list of devices</span> <span class="sd"> :returns: list of devices</span>
<span class="sd"> :raises: util.CommError</span>
<span class="sd"> :raises: CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">devices</span> <span class="o">=</span> <span class="p">[]</span> <span class="n">devices</span> <span class="o">=</span> <span class="p">[]</span>


@@ -204,7 +205,7 @@
<span class="n">devices</span> <span class="o">=</span> <span class="n">Ftdi</span><span class="o">.</span><span class="n">find_all</span><span class="p">([(</span><span class="n">USBDevice</span><span class="o">.</span><span class="n">FTDI_VENDOR_ID</span><span class="p">,</span> <span class="n">USBDevice</span><span class="o">.</span><span class="n">FTDI_PRODUCT_ID</span><span class="p">)],</span> <span class="n">nocache</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="n">devices</span> <span class="o">=</span> <span class="n">Ftdi</span><span class="o">.</span><span class="n">find_all</span><span class="p">([(</span><span class="n">USBDevice</span><span class="o">.</span><span class="n">FTDI_VENDOR_ID</span><span class="p">,</span> <span class="n">USBDevice</span><span class="o">.</span><span class="n">FTDI_PRODUCT_ID</span><span class="p">)],</span> <span class="n">nocache</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>


<span class="k">except</span> <span class="p">(</span><span class="n">usb</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">USBError</span><span class="p">,</span> <span class="n">FtdiError</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="p">(</span><span class="n">usb</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">USBError</span><span class="p">,</span> <span class="n">FtdiError</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error enumerating AD2USB devices: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error enumerating AD2USB devices: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">return</span> <span class="n">devices</span> <span class="k">return</span> <span class="n">devices</span>
</div> </div>
@@ -293,7 +294,7 @@
<span class="sd"> :param no_reader_thread: Whether or not to automatically start the reader thread.</span> <span class="sd"> :param no_reader_thread: Whether or not to automatically start the reader thread.</span>
<span class="sd"> :type no_reader_thread: bool</span> <span class="sd"> :type no_reader_thread: bool</span>


<span class="sd"> :raises: util.NoDeviceError</span>
<span class="sd"> :raises: NoDeviceError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="c"># Set up defaults</span> <span class="c"># Set up defaults</span>
<span class="k">if</span> <span class="n">baudrate</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> <span class="k">if</span> <span class="n">baudrate</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
@@ -313,7 +314,7 @@
<span class="bp">self</span><span class="o">.</span><span class="n">_id</span> <span class="o">=</span> <span class="s">&#39;USB {0}:{1}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">usb_dev</span><span class="o">.</span><span class="n">bus</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">usb_dev</span><span class="o">.</span><span class="n">address</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_id</span> <span class="o">=</span> <span class="s">&#39;USB {0}:{1}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">usb_dev</span><span class="o">.</span><span class="n">bus</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">usb_dev</span><span class="o">.</span><span class="n">address</span><span class="p">)</span>


<span class="k">except</span> <span class="p">(</span><span class="n">usb</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">USBError</span><span class="p">,</span> <span class="n">FtdiError</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="p">(</span><span class="n">usb</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">USBError</span><span class="p">,</span> <span class="n">FtdiError</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;Error opening device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;Error opening device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">True</span> <span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">True</span>
@@ -342,7 +343,7 @@
<span class="sd"> :param data: Data to write</span> <span class="sd"> :param data: Data to write</span>
<span class="sd"> :type data: str</span> <span class="sd"> :type data: str</span>


<span class="sd"> :raises: util.CommError</span>
<span class="sd"> :raises: CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">try</span><span class="p">:</span> <span class="k">try</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write_data</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write_data</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
@@ -350,14 +351,14 @@
<span class="bp">self</span><span class="o">.</span><span class="n">on_write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>


<span class="k">except</span> <span class="n">FtdiError</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="n">FtdiError</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error writing to device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error writing to device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
</div> </div>
<div class="viewcode-block" id="USBDevice.read"><a class="viewcode-back" href="../../pyad2.html#pyad2.devices.USBDevice.read">[docs]</a> <span class="k">def</span> <span class="nf">read</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <div class="viewcode-block" id="USBDevice.read"><a class="viewcode-back" href="../../pyad2.html#pyad2.devices.USBDevice.read">[docs]</a> <span class="k">def</span> <span class="nf">read</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Reads a single character from the device.</span> <span class="sd"> Reads a single character from the device.</span>


<span class="sd"> :returns: The character read from the device.</span> <span class="sd"> :returns: The character read from the device.</span>
<span class="sd"> :raises: util.CommError</span>
<span class="sd"> :raises: CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">ret</span> <span class="o">=</span> <span class="bp">None</span> <span class="n">ret</span> <span class="o">=</span> <span class="bp">None</span>


@@ -365,7 +366,7 @@
<span class="n">ret</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">read_data</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="n">ret</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">read_data</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>


<span class="k">except</span> <span class="p">(</span><span class="n">usb</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">USBError</span><span class="p">,</span> <span class="n">FtdiError</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="p">(</span><span class="n">usb</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">USBError</span><span class="p">,</span> <span class="n">FtdiError</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">return</span> <span class="n">ret</span> <span class="k">return</span> <span class="n">ret</span>
</div> </div>
@@ -379,7 +380,7 @@
<span class="sd"> :type purge_buffer: bool</span> <span class="sd"> :type purge_buffer: bool</span>


<span class="sd"> :returns: The line that was read.</span> <span class="sd"> :returns: The line that was read.</span>
<span class="sd"> :raises: util.CommError, util.TimeoutError</span>
<span class="sd"> :raises: CommError, TimeoutError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>


<span class="k">if</span> <span class="n">purge_buffer</span><span class="p">:</span> <span class="k">if</span> <span class="n">purge_buffer</span><span class="p">:</span>
@@ -421,7 +422,7 @@
<span class="k">if</span> <span class="n">timer</span><span class="p">:</span> <span class="k">if</span> <span class="n">timer</span><span class="p">:</span>
<span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span> <span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span>


<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="n">got_line</span><span class="p">:</span> <span class="k">if</span> <span class="n">got_line</span><span class="p">:</span>
@@ -434,7 +435,7 @@
<span class="k">if</span> <span class="n">timer</span><span class="o">.</span><span class="n">is_alive</span><span class="p">():</span> <span class="k">if</span> <span class="n">timer</span><span class="o">.</span><span class="n">is_alive</span><span class="p">():</span>
<span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span> <span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">TimeoutError</span><span class="p">(</span><span class="s">&#39;Timeout while waiting for line terminator.&#39;</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">TimeoutError</span><span class="p">(</span><span class="s">&#39;Timeout while waiting for line terminator.&#39;</span><span class="p">)</span>


<span class="k">return</span> <span class="n">ret</span> <span class="k">return</span> <span class="n">ret</span>


@@ -457,7 +458,7 @@
<span class="sd"> :type pattern: str</span> <span class="sd"> :type pattern: str</span>


<span class="sd"> :returns: list of devices</span> <span class="sd"> :returns: list of devices</span>
<span class="sd"> :raises: util.CommError</span>
<span class="sd"> :raises: CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">devices</span> <span class="o">=</span> <span class="p">[]</span> <span class="n">devices</span> <span class="o">=</span> <span class="p">[]</span>


@@ -468,7 +469,7 @@
<span class="n">devices</span> <span class="o">=</span> <span class="n">serial</span><span class="o">.</span><span class="n">tools</span><span class="o">.</span><span class="n">list_ports</span><span class="o">.</span><span class="n">comports</span><span class="p">()</span> <span class="n">devices</span> <span class="o">=</span> <span class="n">serial</span><span class="o">.</span><span class="n">tools</span><span class="o">.</span><span class="n">list_ports</span><span class="o">.</span><span class="n">comports</span><span class="p">()</span>


<span class="k">except</span> <span class="n">SerialException</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="n">SerialException</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error enumerating serial devices: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error enumerating serial devices: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">return</span> <span class="n">devices</span> <span class="k">return</span> <span class="n">devices</span>
</div> </div>
@@ -513,14 +514,14 @@
<span class="sd"> :param no_reader_thread: Whether or not to automatically start the reader thread.</span> <span class="sd"> :param no_reader_thread: Whether or not to automatically start the reader thread.</span>
<span class="sd"> :type no_reader_thread: bool</span> <span class="sd"> :type no_reader_thread: bool</span>


<span class="sd"> :raises: util.NoDeviceError</span>
<span class="sd"> :raises: NoDeviceError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="c"># Set up the defaults</span> <span class="c"># Set up the defaults</span>
<span class="k">if</span> <span class="n">baudrate</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> <span class="k">if</span> <span class="n">baudrate</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">baudrate</span> <span class="o">=</span> <span class="n">SerialDevice</span><span class="o">.</span><span class="n">BAUDRATE</span> <span class="n">baudrate</span> <span class="o">=</span> <span class="n">SerialDevice</span><span class="o">.</span><span class="n">BAUDRATE</span>


<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_port</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_port</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;No device interface specified.&#39;</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;No device interface specified.&#39;</span><span class="p">)</span>


<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_port</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_port</span>


@@ -535,7 +536,7 @@
<span class="c"># all issues with it.</span> <span class="c"># all issues with it.</span>


<span class="k">except</span> <span class="p">(</span><span class="n">serial</span><span class="o">.</span><span class="n">SerialException</span><span class="p">,</span> <span class="ne">ValueError</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="p">(</span><span class="n">serial</span><span class="o">.</span><span class="n">SerialException</span><span class="p">,</span> <span class="ne">ValueError</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;Error opening device on port {0}.&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_port</span><span class="p">),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;Error opening device on port {0}.&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_port</span><span class="p">),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">True</span> <span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">True</span>
@@ -561,7 +562,7 @@
<span class="sd"> :param data: The data to write.</span> <span class="sd"> :param data: The data to write.</span>
<span class="sd"> :type data: str</span> <span class="sd"> :type data: str</span>


<span class="sd"> :raises: util.CommError</span>
<span class="sd"> :raises: CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">try</span><span class="p">:</span> <span class="k">try</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
@@ -570,7 +571,7 @@
<span class="k">pass</span> <span class="k">pass</span>


<span class="k">except</span> <span class="n">serial</span><span class="o">.</span><span class="n">SerialException</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="n">serial</span><span class="o">.</span><span class="n">SerialException</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error writing to device.&#39;</span><span class="p">,</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error writing to device.&#39;</span><span class="p">,</span> <span class="n">err</span><span class="p">)</span>


<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">on_write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
@@ -580,7 +581,7 @@
<span class="sd"> Reads a single character from the device.</span> <span class="sd"> Reads a single character from the device.</span>


<span class="sd"> :returns: The character read from the device.</span> <span class="sd"> :returns: The character read from the device.</span>
<span class="sd"> :raises: util.CommError</span>
<span class="sd"> :raises: CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">ret</span> <span class="o">=</span> <span class="bp">None</span> <span class="n">ret</span> <span class="o">=</span> <span class="bp">None</span>


@@ -588,7 +589,7 @@
<span class="n">ret</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="n">ret</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>


<span class="k">except</span> <span class="n">serial</span><span class="o">.</span><span class="n">SerialException</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="n">serial</span><span class="o">.</span><span class="n">SerialException</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">return</span> <span class="n">ret</span> <span class="k">return</span> <span class="n">ret</span>
</div> </div>
@@ -602,7 +603,7 @@
<span class="sd"> :type purge_buffer: bool</span> <span class="sd"> :type purge_buffer: bool</span>


<span class="sd"> :returns: The line read.</span> <span class="sd"> :returns: The line read.</span>
<span class="sd"> :raises: util.CommError, util.TimeoutError</span>
<span class="sd"> :raises: CommError, TimeoutError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">timeout_event</span><span class="p">():</span> <span class="k">def</span> <span class="nf">timeout_event</span><span class="p">():</span>
<span class="n">timeout_event</span><span class="o">.</span><span class="n">reading</span> <span class="o">=</span> <span class="bp">False</span> <span class="n">timeout_event</span><span class="o">.</span><span class="n">reading</span> <span class="o">=</span> <span class="bp">False</span>
@@ -640,7 +641,7 @@
<span class="k">if</span> <span class="n">timer</span><span class="p">:</span> <span class="k">if</span> <span class="n">timer</span><span class="p">:</span>
<span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span> <span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span>


<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="n">got_line</span><span class="p">:</span> <span class="k">if</span> <span class="n">got_line</span><span class="p">:</span>
@@ -653,13 +654,13 @@
<span class="k">if</span> <span class="n">timer</span><span class="o">.</span><span class="n">is_alive</span><span class="p">():</span> <span class="k">if</span> <span class="n">timer</span><span class="o">.</span><span class="n">is_alive</span><span class="p">():</span>
<span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span> <span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">TimeoutError</span><span class="p">(</span><span class="s">&#39;Timeout while waiting for line terminator.&#39;</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">TimeoutError</span><span class="p">(</span><span class="s">&#39;Timeout while waiting for line terminator.&#39;</span><span class="p">)</span>


<span class="k">return</span> <span class="n">ret</span> <span class="k">return</span> <span class="n">ret</span>
</div></div> </div></div>
<div class="viewcode-block" id="SocketDevice"><a class="viewcode-back" href="../../pyad2.html#pyad2.devices.SocketDevice">[docs]</a><span class="k">class</span> <span class="nc">SocketDevice</span><span class="p">(</span><span class="n">Device</span><span class="p">):</span> <div class="viewcode-block" id="SocketDevice"><a class="viewcode-back" href="../../pyad2.html#pyad2.devices.SocketDevice">[docs]</a><span class="k">class</span> <span class="nc">SocketDevice</span><span class="p">(</span><span class="n">Device</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Device that supports communication with an AD2USB that is exposed via ser2sock or another</span>
<span class="sd"> Device that supports communication with an AD2 that is exposed via ser2sock or another</span>
<span class="sd"> Serial to IP interface.</span> <span class="sd"> Serial to IP interface.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>


@@ -783,7 +784,7 @@
<span class="sd"> :param no_reader_thread: Whether or not to automatically open the reader thread.</span> <span class="sd"> :param no_reader_thread: Whether or not to automatically open the reader thread.</span>
<span class="sd"> :type no_reader_thread: bool</span> <span class="sd"> :type no_reader_thread: bool</span>


<span class="sd"> :raises: util.NoDeviceError, util.CommError</span>
<span class="sd"> :raises: NoDeviceError, CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>


<span class="k">try</span><span class="p">:</span> <span class="k">try</span><span class="p">:</span>
@@ -797,7 +798,7 @@
<span class="bp">self</span><span class="o">.</span><span class="n">_id</span> <span class="o">=</span> <span class="s">&#39;{0}:{1}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_host</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_port</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_id</span> <span class="o">=</span> <span class="s">&#39;{0}:{1}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_host</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_port</span><span class="p">)</span>


<span class="k">except</span> <span class="n">socket</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="n">socket</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;Error opening device at {0}:{1}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_host</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_port</span><span class="p">),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">NoDeviceError</span><span class="p">(</span><span class="s">&#39;Error opening device at {0}:{1}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_host</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_port</span><span class="p">),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">True</span> <span class="bp">self</span><span class="o">.</span><span class="n">_running</span> <span class="o">=</span> <span class="bp">True</span>
@@ -830,7 +831,7 @@
<span class="sd"> :type data: str</span> <span class="sd"> :type data: str</span>


<span class="sd"> :returns: The number of bytes sent.</span> <span class="sd"> :returns: The number of bytes sent.</span>
<span class="sd"> :raises: util.CommError</span>
<span class="sd"> :raises: CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">data_sent</span> <span class="o">=</span> <span class="bp">None</span> <span class="n">data_sent</span> <span class="o">=</span> <span class="bp">None</span>


@@ -838,12 +839,12 @@
<span class="n">data_sent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="n">data_sent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>


<span class="k">if</span> <span class="n">data_sent</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="k">if</span> <span class="n">data_sent</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error writing to device.&#39;</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error writing to device.&#39;</span><span class="p">)</span>


<span class="bp">self</span><span class="o">.</span><span class="n">on_write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>


<span class="k">except</span> <span class="p">(</span><span class="n">SSL</span><span class="o">.</span><span class="n">Error</span><span class="p">,</span> <span class="n">socket</span><span class="o">.</span><span class="n">error</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="p">(</span><span class="n">SSL</span><span class="o">.</span><span class="n">Error</span><span class="p">,</span> <span class="n">socket</span><span class="o">.</span><span class="n">error</span><span class="p">),</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error writing to device.&#39;</span><span class="p">,</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error writing to device.&#39;</span><span class="p">,</span> <span class="n">err</span><span class="p">)</span>


<span class="k">return</span> <span class="n">data_sent</span> <span class="k">return</span> <span class="n">data_sent</span>
</div> </div>
@@ -852,7 +853,7 @@
<span class="sd"> Reads a single character from the device.</span> <span class="sd"> Reads a single character from the device.</span>


<span class="sd"> :returns: The character read from the device.</span> <span class="sd"> :returns: The character read from the device.</span>
<span class="sd"> :raises: util.CommError</span>
<span class="sd"> :raises: CommError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">data</span> <span class="o">=</span> <span class="bp">None</span> <span class="n">data</span> <span class="o">=</span> <span class="bp">None</span>


@@ -860,7 +861,7 @@
<span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">recv</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="o">.</span><span class="n">recv</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>


<span class="k">except</span> <span class="n">socket</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="n">socket</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error while reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error while reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">return</span> <span class="n">data</span> <span class="k">return</span> <span class="n">data</span>
</div> </div>
@@ -874,7 +875,7 @@
<span class="sd"> :type purge_buffer: bool</span> <span class="sd"> :type purge_buffer: bool</span>


<span class="sd"> :returns: The line read from the device.</span> <span class="sd"> :returns: The line read from the device.</span>
<span class="sd"> :raises: util.CommError, util.TimeoutError</span>
<span class="sd"> :raises: CommError, TimeoutError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>


<span class="k">if</span> <span class="n">purge_buffer</span><span class="p">:</span> <span class="k">if</span> <span class="n">purge_buffer</span><span class="p">:</span>
@@ -916,7 +917,7 @@
<span class="k">if</span> <span class="n">timer</span><span class="p">:</span> <span class="k">if</span> <span class="n">timer</span><span class="p">:</span>
<span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span> <span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span>


<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error reading from device: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">err</span><span class="p">)),</span> <span class="n">err</span><span class="p">)</span>


<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="n">got_line</span><span class="p">:</span> <span class="k">if</span> <span class="n">got_line</span><span class="p">:</span>
@@ -929,7 +930,7 @@
<span class="k">if</span> <span class="n">timer</span><span class="o">.</span><span class="n">is_alive</span><span class="p">():</span> <span class="k">if</span> <span class="n">timer</span><span class="o">.</span><span class="n">is_alive</span><span class="p">():</span>
<span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span> <span class="n">timer</span><span class="o">.</span><span class="n">cancel</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span> <span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">TimeoutError</span><span class="p">(</span><span class="s">&#39;Timeout while waiting for line terminator.&#39;</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">TimeoutError</span><span class="p">(</span><span class="s">&#39;Timeout while waiting for line terminator.&#39;</span><span class="p">)</span>


<span class="k">return</span> <span class="n">ret</span> <span class="k">return</span> <span class="n">ret</span>
</div> </div>
@@ -958,10 +959,9 @@
<span class="bp">self</span><span class="o">.</span><span class="n">_device</span> <span class="o">=</span> <span class="n">SSL</span><span class="o">.</span><span class="n">Connection</span><span class="p">(</span><span class="n">ctx</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span> <span class="o">=</span> <span class="n">SSL</span><span class="o">.</span><span class="n">Connection</span><span class="p">(</span><span class="n">ctx</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="p">)</span>


<span class="k">except</span> <span class="n">SSL</span><span class="o">.</span><span class="n">Error</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span> <span class="k">except</span> <span class="n">SSL</span><span class="o">.</span><span class="n">Error</span><span class="p">,</span> <span class="n">err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error setting up SSL connection.&#39;</span><span class="p">,</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommError</span><span class="p">(</span><span class="s">&#39;Error setting up SSL connection.&#39;</span><span class="p">,</span> <span class="n">err</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">_verify_ssl_callback</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">connection</span><span class="p">,</span> <span class="n">x509</span><span class="p">,</span> <span class="n">errnum</span><span class="p">,</span> <span class="n">errdepth</span><span class="p">,</span> <span class="n">ok</span><span class="p">):</span> <span class="k">def</span> <span class="nf">_verify_ssl_callback</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">connection</span><span class="p">,</span> <span class="n">x509</span><span class="p">,</span> <span class="n">errnum</span><span class="p">,</span> <span class="n">errdepth</span><span class="p">,</span> <span class="n">ok</span><span class="p">):</span>
<span class="c">#print ok</span>
<span class="k">return</span> <span class="n">ok</span></div> <span class="k">return</span> <span class="n">ok</span></div>
</pre></div> </pre></div>




+ 8
- 0
docs/_build/html/_modules/pyad2/event/event.html View File

@@ -48,6 +48,14 @@
<h1>Source code for pyad2.event.event</h1><div class="highlight"><pre> <h1>Source code for pyad2.event.event</h1><div class="highlight"><pre>
<span class="c"># event.py (improved)</span> <span class="c"># event.py (improved)</span>
<span class="c">#</span>

<span class="c"># Based on pyevent originally found at http://www.emptypage.jp/notes/pyevent.en.html</span>
<span class="c"># </span>
<span class="c"># License: https://creativecommons.org/licenses/by/2.1/jp/deed.en</span>
<span class="c">#</span>
<span class="c"># Changes:</span>
<span class="c"># Added type check in fire()</span>


<div class="viewcode-block" id="Event"><a class="viewcode-back" href="../../../pyad2.event.html#pyad2.event.event.Event">[docs]</a><span class="k">class</span> <span class="nc">Event</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <div class="viewcode-block" id="Event"><a class="viewcode-back" href="../../../pyad2.event.html#pyad2.event.event.Event">[docs]</a><span class="k">class</span> <span class="nc">Event</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>




+ 25
- 17
docs/_build/html/_modules/pyad2/messages.html View File

@@ -48,20 +48,30 @@
<h1>Source code for pyad2.messages</h1><div class="highlight"><pre> <h1>Source code for pyad2.messages</h1><div class="highlight"><pre>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Message representations received from the panel through the AD2USB.</span>
<span class="sd">Message representations received from the panel through the AD2 devices.</span>


<span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span> <span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>


<span class="kn">import</span> <span class="nn">re</span> <span class="kn">import</span> <span class="nn">re</span>
<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">util</span>

<span class="kn">from</span> <span class="nn">.util</span> <span class="kn">import</span> <span class="n">InvalidMessageError</span>


<div class="viewcode-block" id="BaseMessage"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.BaseMessage">[docs]</a><span class="k">class</span> <span class="nc">BaseMessage</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <div class="viewcode-block" id="BaseMessage"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.BaseMessage">[docs]</a><span class="k">class</span> <span class="nc">BaseMessage</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Base class for messages.</span> <span class="sd"> Base class for messages.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Constructor</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">raw</span> <span class="o">=</span> <span class="bp">None</span> <span class="bp">self</span><span class="o">.</span><span class="n">raw</span> <span class="o">=</span> <span class="bp">None</span>

<span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> String conversion operator.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">raw</span>
</div> </div>
<div class="viewcode-block" id="Message"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.Message">[docs]</a><span class="k">class</span> <span class="nc">Message</span><span class="p">(</span><span class="n">BaseMessage</span><span class="p">):</span> <div class="viewcode-block" id="Message"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.Message">[docs]</a><span class="k">class</span> <span class="nc">Message</span><span class="p">(</span><span class="n">BaseMessage</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -111,12 +121,12 @@
<span class="sd"> :param data: The message data.</span> <span class="sd"> :param data: The message data.</span>
<span class="sd"> :type data: str</span> <span class="sd"> :type data: str</span>


<span class="sd"> :raises: util.InvalidMessageError</span>
<span class="sd"> :raises: InvalidMessageError</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">m</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_regex</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="n">m</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_regex</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>


<span class="k">if</span> <span class="n">m</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> <span class="k">if</span> <span class="n">m</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">InvalidMessageError</span><span class="p">(</span><span class="s">&#39;Received invalid message: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
<span class="k">raise</span> <span class="n">InvalidMessageError</span><span class="p">(</span><span class="s">&#39;Received invalid message: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>


<span class="bp">self</span><span class="o">.</span><span class="n">bitfield</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">numeric_code</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">panel_data</span><span class="p">,</span> <span class="n">alpha</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</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="bp">self</span><span class="o">.</span><span class="n">bitfield</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">numeric_code</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">panel_data</span><span class="p">,</span> <span class="n">alpha</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</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="bp">self</span><span class="o">.</span><span class="n">mask</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">panel_data</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="mi">3</span><span class="o">+</span><span class="mi">8</span><span class="p">],</span> <span class="mi">16</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">panel_data</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="mi">3</span><span class="o">+</span><span class="mi">8</span><span class="p">],</span> <span class="mi">16</span><span class="p">)</span>
@@ -150,7 +160,7 @@
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> String conversion operator.</span> <span class="sd"> String conversion operator.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="s">&#39;msg &gt; {0:0&lt;9} [{1}{2}{3}] -- ({4}) {5}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">hex</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mask</span><span class="p">),</span> <span class="mi">1</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ready</span> <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">armed_away</span> <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">armed_home</span> <span class="k">else</span> <span class="mi">0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">numeric_code</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">raw</span>
</div> </div>
<div class="viewcode-block" id="ExpanderMessage"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.ExpanderMessage">[docs]</a><span class="k">class</span> <span class="nc">ExpanderMessage</span><span class="p">(</span><span class="n">BaseMessage</span><span class="p">):</span> <div class="viewcode-block" id="ExpanderMessage"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.ExpanderMessage">[docs]</a><span class="k">class</span> <span class="nc">ExpanderMessage</span><span class="p">(</span><span class="n">BaseMessage</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -158,7 +168,9 @@
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>


<span class="n">ZONE</span> <span class="o">=</span> <span class="mi">0</span> <span class="n">ZONE</span> <span class="o">=</span> <span class="mi">0</span>
<span class="sd">&quot;&quot;&quot;Flag indicating that the expander message relates to a Zone Expander.&quot;&quot;&quot;</span>
<span class="n">RELAY</span> <span class="o">=</span> <span class="mi">1</span> <span class="n">RELAY</span> <span class="o">=</span> <span class="mi">1</span>
<span class="sd">&quot;&quot;&quot;Flag indicating that the expander message relates to a Relay Expander.&quot;&quot;&quot;</span>


<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -180,13 +192,7 @@
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> String conversion operator.</span> <span class="sd"> String conversion operator.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">expander_type</span> <span class="o">=</span> <span class="s">&#39;UNKWN&#39;</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">ZONE</span><span class="p">:</span>
<span class="n">expander_type</span> <span class="o">=</span> <span class="s">&#39;ZONE&#39;</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">RELAY</span><span class="p">:</span>
<span class="n">expander_type</span> <span class="o">=</span> <span class="s">&#39;RELAY&#39;</span>

<span class="k">return</span> <span class="s">&#39;exp &gt; [{0: &lt;5}] {1}/{2} -- {3}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">expander_type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">address</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">channel</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">raw</span>


<span class="k">def</span> <span class="nf">_parse_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span> <span class="k">def</span> <span class="nf">_parse_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -205,12 +211,14 @@
<span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>


<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">InvalidMessageError</span><span class="p">(</span><span class="s">&#39;Received invalid message: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
<span class="k">raise</span> <span class="n">InvalidMessageError</span><span class="p">(</span><span class="s">&#39;Received invalid message: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>


<span class="k">if</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!EXP&#39;</span><span class="p">:</span> <span class="k">if</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!EXP&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">ZONE</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">ZONE</span>
<span class="k">elif</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!REL&#39;</span><span class="p">:</span> <span class="k">elif</span> <span class="n">header</span> <span class="o">==</span> <span class="s">&#39;!REL&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">RELAY</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">RELAY</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">InvalidMessageError</span><span class="p">(</span><span class="s">&#39;Unknown expander message header: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
</div> </div>
<div class="viewcode-block" id="RFMessage"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.RFMessage">[docs]</a><span class="k">class</span> <span class="nc">RFMessage</span><span class="p">(</span><span class="n">BaseMessage</span><span class="p">):</span> <div class="viewcode-block" id="RFMessage"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.RFMessage">[docs]</a><span class="k">class</span> <span class="nc">RFMessage</span><span class="p">(</span><span class="n">BaseMessage</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -238,7 +246,7 @@
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> String conversion operator.</span> <span class="sd"> String conversion operator.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="s">&#39;rf &gt; {0}: {1:x}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">serial_number</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">raw</span>


<span class="k">def</span> <span class="nf">_parse_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span> <span class="k">def</span> <span class="nf">_parse_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -266,7 +274,7 @@
<span class="bp">self</span><span class="o">.</span><span class="n">loop</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">is_bit_set</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">loop</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">is_bit_set</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span>


<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">InvalidMessageError</span><span class="p">(</span><span class="s">&#39;Received invalid message: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
<span class="k">raise</span> <span class="n">InvalidMessageError</span><span class="p">(</span><span class="s">&#39;Received invalid message: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>


</div> </div>
<div class="viewcode-block" id="LRRMessage"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.LRRMessage">[docs]</a><span class="k">class</span> <span class="nc">LRRMessage</span><span class="p">(</span><span class="n">BaseMessage</span><span class="p">):</span> <div class="viewcode-block" id="LRRMessage"><a class="viewcode-back" href="../../pyad2.html#pyad2.messages.LRRMessage">[docs]</a><span class="k">class</span> <span class="nc">LRRMessage</span><span class="p">(</span><span class="n">BaseMessage</span><span class="p">):</span>
@@ -293,7 +301,7 @@
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> String conversion operator.</span> <span class="sd"> String conversion operator.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="s">&#39;lrr &gt; {0} @ {1} -- {2}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">event_data</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_type</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">raw</span>


<span class="k">def</span> <span class="nf">_parse_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span> <span class="k">def</span> <span class="nf">_parse_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -309,7 +317,7 @@
<span class="bp">self</span><span class="o">.</span><span class="n">event_data</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_type</span> <span class="o">=</span> <span class="n">values</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39;,&#39;</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_data</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_type</span> <span class="o">=</span> <span class="n">values</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39;,&#39;</span><span class="p">)</span>


<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">util</span><span class="o">.</span><span class="n">InvalidMessageError</span><span class="p">(</span><span class="s">&#39;Received invalid message: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">data</span><span class="p">))</span></div>
<span class="k">raise</span> <span class="n">InvalidMessageError</span><span class="p">(</span><span class="s">&#39;Received invalid message: {0}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">data</span><span class="p">))</span></div>
</pre></div> </pre></div>


</div> </div>


+ 3
- 4
docs/_build/html/_modules/pyad2/util.html View File

@@ -48,14 +48,13 @@
<h1>Source code for pyad2.util</h1><div class="highlight"><pre> <h1>Source code for pyad2.util</h1><div class="highlight"><pre>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Provides utility classes for the AD2USB devices.</span>
<span class="sd">Provides utility classes for the AD2 devices.</span>


<span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span> <span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>


<span class="kn">import</span> <span class="nn">ad2</span> <span class="kn">import</span> <span class="nn">ad2</span>
<span class="kn">import</span> <span class="nn">time</span> <span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">traceback</span>
<span class="kn">import</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="nn">threading</span>


<div class="viewcode-block" id="NoDeviceError"><a class="viewcode-back" href="../../pyad2.html#pyad2.util.NoDeviceError">[docs]</a><span class="k">class</span> <span class="nc">NoDeviceError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span> <div class="viewcode-block" id="NoDeviceError"><a class="viewcode-back" href="../../pyad2.html#pyad2.util.NoDeviceError">[docs]</a><span class="k">class</span> <span class="nc">NoDeviceError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
@@ -84,7 +83,7 @@
</div> </div>
<div class="viewcode-block" id="Firmware"><a class="viewcode-back" href="../../pyad2.html#pyad2.util.Firmware">[docs]</a><span class="k">class</span> <span class="nc">Firmware</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <div class="viewcode-block" id="Firmware"><a class="viewcode-back" href="../../pyad2.html#pyad2.util.Firmware">[docs]</a><span class="k">class</span> <span class="nc">Firmware</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Represents firmware for the AD2USB/AD2SERIAL devices.</span>
<span class="sd"> Represents firmware for the AD2 devices.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>


<span class="c"># Constants</span> <span class="c"># Constants</span>
@@ -98,7 +97,7 @@
<span class="nd">@staticmethod</span> <span class="nd">@staticmethod</span>
<div class="viewcode-block" id="Firmware.upload"><a class="viewcode-back" href="../../pyad2.html#pyad2.util.Firmware.upload">[docs]</a> <span class="k">def</span> <span class="nf">upload</span><span class="p">(</span><span class="n">dev</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">progress_callback</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> <div class="viewcode-block" id="Firmware.upload"><a class="viewcode-back" href="../../pyad2.html#pyad2.util.Firmware.upload">[docs]</a> <span class="k">def</span> <span class="nf">upload</span><span class="p">(</span><span class="n">dev</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">progress_callback</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Uploads firmware to an AD2USB/AD2SERIAL device.</span>
<span class="sd"> Uploads firmware to an AD2 device.</span>


<span class="sd"> :param filename: The firmware filename</span> <span class="sd"> :param filename: The firmware filename</span>
<span class="sd"> :type filename: str</span> <span class="sd"> :type filename: str</span>


+ 9
- 10
docs/_build/html/_modules/pyad2/zonetracking.html View File

@@ -48,15 +48,16 @@
<h1>Source code for pyad2.zonetracking</h1><div class="highlight"><pre> <h1>Source code for pyad2.zonetracking</h1><div class="highlight"><pre>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Provides zone tracking functionality for the AD2USB device family.</span>
<span class="sd">Provides zone tracking functionality for the AD2 device family.</span>


<span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span> <span class="sd">.. moduleauthor:: Scott Petersen &lt;scott@nutech.com&gt;</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>


<span class="kn">import</span> <span class="nn">re</span> <span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">time</span> <span class="kn">import</span> <span class="nn">time</span>

<span class="kn">from</span> <span class="nn">.event</span> <span class="kn">import</span> <span class="n">event</span> <span class="kn">from</span> <span class="nn">.event</span> <span class="kn">import</span> <span class="n">event</span>
<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">messages</span>
<span class="kn">from</span> <span class="nn">.messages</span> <span class="kn">import</span> <span class="n">ExpanderMessage</span>


<div class="viewcode-block" id="Zone"><a class="viewcode-back" href="../../pyad2.html#pyad2.zonetracking.Zone">[docs]</a><span class="k">class</span> <span class="nc">Zone</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <div class="viewcode-block" id="Zone"><a class="viewcode-back" href="../../pyad2.html#pyad2.zonetracking.Zone">[docs]</a><span class="k">class</span> <span class="nc">Zone</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>
@@ -126,10 +127,8 @@
<span class="sd"> :param message: Message to use to update the zone tracking.</span> <span class="sd"> :param message: Message to use to update the zone tracking.</span>
<span class="sd"> :type message: Message or ExpanderMessage</span> <span class="sd"> :type message: Message or ExpanderMessage</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="n">zone</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>

<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">messages</span><span class="o">.</span><span class="n">ExpanderMessage</span><span class="p">):</span>
<span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">messages</span><span class="o">.</span><span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">ZONE</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">ExpanderMessage</span><span class="p">):</span>
<span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">ExpanderMessage</span><span class="o">.</span><span class="n">ZONE</span><span class="p">:</span>
<span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_expander_to_zone</span><span class="p">(</span><span class="n">message</span><span class="o">.</span><span class="n">address</span><span class="p">,</span> <span class="n">message</span><span class="o">.</span><span class="n">channel</span><span class="p">)</span> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_expander_to_zone</span><span class="p">(</span><span class="n">message</span><span class="o">.</span><span class="n">address</span><span class="p">,</span> <span class="n">message</span><span class="o">.</span><span class="n">channel</span><span class="p">)</span>


<span class="n">status</span> <span class="o">=</span> <span class="n">Zone</span><span class="o">.</span><span class="n">CLEAR</span> <span class="n">status</span> <span class="o">=</span> <span class="n">Zone</span><span class="o">.</span><span class="n">CLEAR</span>
@@ -138,6 +137,9 @@
<span class="k">elif</span> <span class="n">message</span><span class="o">.</span><span class="n">value</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> <span class="k">elif</span> <span class="n">message</span><span class="o">.</span><span class="n">value</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">Zone</span><span class="o">.</span><span class="n">CHECK</span> <span class="n">status</span> <span class="o">=</span> <span class="n">Zone</span><span class="o">.</span><span class="n">CHECK</span>


<span class="c"># NOTE: Expander zone faults are handled differently than regular messages.</span>
<span class="c"># We don&#39;t include them in self._zones_faulted because they are not reported</span>
<span class="c"># by the panel in it&#39;s rolling list of faults.</span>
<span class="k">try</span><span class="p">:</span> <span class="k">try</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_update_zone</span><span class="p">(</span><span class="n">zone</span><span class="p">,</span> <span class="n">status</span><span class="o">=</span><span class="n">status</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_update_zone</span><span class="p">(</span><span class="n">zone</span><span class="p">,</span> <span class="n">status</span><span class="o">=</span><span class="n">status</span><span class="p">)</span>


@@ -317,10 +319,7 @@


<span class="sd"> :returns: Whether or not the zone is expired.</span> <span class="sd"> :returns: Whether or not the zone is expired.</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">_zones</span><span class="p">[</span><span class="n">zone</span><span class="p">]</span><span class="o">.</span><span class="n">timestamp</span> <span class="o">+</span> <span class="n">Zonetracker</span><span class="o">.</span><span class="n">EXPIRE</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">True</span>

<span class="k">return</span> <span class="bp">False</span>
<span class="k">return</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">_zones</span><span class="p">[</span><span class="n">zone</span><span class="p">]</span><span class="o">.</span><span class="n">timestamp</span> <span class="o">+</span> <span class="n">Zonetracker</span><span class="o">.</span><span class="n">EXPIRE</span>


<span class="k">def</span> <span class="nf">_expander_to_zone</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">address</span><span class="p">,</span> <span class="n">channel</span><span class="p">):</span> <span class="k">def</span> <span class="nf">_expander_to_zone</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">address</span><span class="p">,</span> <span class="n">channel</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span> <span class="sd">&quot;&quot;&quot;</span>


+ 1
- 1
docs/_build/html/_sources/index.txt View File

@@ -1,4 +1,4 @@
.. pyad2usb documentation master file, created by
.. pyad2 documentation master file, created by
sphinx-quickstart on Sat Jun 8 14:38:46 2013. sphinx-quickstart on Sat Jun 8 14:38:46 2013.
You can adapt this file completely to your liking, but it should at least You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive. contain the root `toctree` directive.


+ 0
- 19
docs/_build/html/_sources/pyad2usb.event.txt View File

@@ -1,19 +0,0 @@
event Package
=============

:mod:`event` Package
--------------------

.. automodule:: pyad2.event
:members:
:undoc-members:
:show-inheritance:

:mod:`event` Module
-------------------

.. automodule:: pyad2.event.event
:members:
:undoc-members:
:show-inheritance:


+ 0
- 58
docs/_build/html/_sources/pyad2usb.txt View File

@@ -1,58 +0,0 @@
pyad2usb Package
================

:mod:`ad2` Module
--------------------

.. automodule:: pyad2.ad2
:members:
:undoc-members:
:show-inheritance:

:mod:`devices` Module
---------------------

.. automodule:: pyad2.devices
:members:
:undoc-members:
:show-inheritance:

:mod:`util` Module
------------------

.. automodule:: pyad2.util
:members:
:undoc-members:
:show-inheritance:

:mod:`zonetracking` Module
--------------------------

.. automodule:: pyad2.zonetracking
:members:
:undoc-members:
:show-inheritance:

:mod:`panels` Module
--------------------

.. automodule:: pyad2.panels
:members:
:undoc-members:
:show-inheritance:

:mod:`messages` Module
----------------------

.. automodule:: pyad2.messages
:members:
:undoc-members:
:show-inheritance:

Subpackages
-----------

.. toctree::

pyad2usb.event


+ 21
- 21
docs/_build/html/genindex.html View File

@@ -77,9 +77,17 @@
<dt><a href="pyad2.html#pyad2.ad2.AD2">AD2 (class in pyad2.ad2)</a> <dt><a href="pyad2.html#pyad2.ad2.AD2">AD2 (class in pyad2.ad2)</a>
</dt> </dt>


<dt><a href="pyad2.html#pyad2.ad2.AD2Factory">AD2Factory (class in pyad2.ad2)</a>
</dt>

</dl></td> </dl></td>
<td style="width: 33%" valign="top"><dl> <td style="width: 33%" valign="top"><dl>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.DetectThread">AD2Factory.DetectThread (class in pyad2.ad2)</a>
</dt>

<dt><a href="pyad2.event.html#pyad2.event.event.EventHandler.add">add() (pyad2.event.event.EventHandler method)</a> <dt><a href="pyad2.event.html#pyad2.event.event.EventHandler.add">add() (pyad2.event.event.EventHandler method)</a>
</dt> </dt>


@@ -135,7 +143,7 @@


<dd><dl> <dd><dl>
<dt><a href="pyad2.html#pyad2.ad2.Overseer.close">(pyad2.ad2.Overseer method)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.close">(pyad2.ad2.AD2Factory method)</a>
</dt> </dt>


@@ -160,7 +168,7 @@
</dt> </dt>


<dt><a href="pyad2.html#pyad2.ad2.Overseer.create">create() (pyad2.ad2.Overseer class method)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.create">create() (pyad2.ad2.AD2Factory class method)</a>
</dt> </dt>


</dl></td> </dl></td>
@@ -184,7 +192,7 @@
</dt> </dt>


<dt><a href="pyad2.html#pyad2.ad2.Overseer.devices">devices() (pyad2.ad2.Overseer class method)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.devices">devices() (pyad2.ad2.AD2Factory class method)</a>
</dt> </dt>


</dl></td> </dl></td>
@@ -244,7 +252,7 @@
</dl></td> </dl></td>
<td style="width: 33%" valign="top"><dl> <td style="width: 33%" valign="top"><dl>
<dt><a href="pyad2.html#pyad2.ad2.Overseer.find_all">find_all() (pyad2.ad2.Overseer class method)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.find_all">find_all() (pyad2.ad2.AD2Factory class method)</a>
</dt> </dt>


<dd><dl> <dd><dl>
@@ -290,7 +298,7 @@
</dl></td> </dl></td>
<td style="width: 33%" valign="top"><dl> <td style="width: 33%" valign="top"><dl>
<dt><a href="pyad2.html#pyad2.ad2.Overseer.get_device">get_device() (pyad2.ad2.Overseer method)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.get_device">get_device() (pyad2.ad2.AD2Factory method)</a>
</dt> </dt>


</dl></td> </dl></td>
@@ -378,7 +386,7 @@
</dt> </dt>


<dt><a href="pyad2.html#pyad2.ad2.Overseer.on_attached">on_attached (pyad2.ad2.Overseer attribute)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.on_attached">on_attached (pyad2.ad2.AD2Factory attribute)</a>
</dt> </dt>


@@ -404,7 +412,7 @@
</dt> </dt>


<dt><a href="pyad2.html#pyad2.ad2.Overseer.on_detached">on_detached (pyad2.ad2.Overseer attribute)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.on_detached">on_detached (pyad2.ad2.AD2Factory attribute)</a>
</dt> </dt>


@@ -427,12 +435,12 @@
<dt><a href="pyad2.html#pyad2.ad2.AD2.on_lrr_message">on_lrr_message (pyad2.ad2.AD2 attribute)</a> <dt><a href="pyad2.html#pyad2.ad2.AD2.on_lrr_message">on_lrr_message (pyad2.ad2.AD2 attribute)</a>
</dt> </dt>


</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="pyad2.html#pyad2.ad2.AD2.on_message">on_message (pyad2.ad2.AD2 attribute)</a> <dt><a href="pyad2.html#pyad2.ad2.AD2.on_message">on_message (pyad2.ad2.AD2 attribute)</a>
</dt> </dt>


</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="pyad2.html#pyad2.ad2.AD2.on_open">on_open (pyad2.ad2.AD2 attribute)</a> <dt><a href="pyad2.html#pyad2.ad2.AD2.on_open">on_open (pyad2.ad2.AD2 attribute)</a>
</dt> </dt>
@@ -509,14 +517,6 @@
</dt> </dt>


</dl></dd> </dl></dd>
<dt><a href="pyad2.html#pyad2.ad2.Overseer">Overseer (class in pyad2.ad2)</a>
</dt>

<dt><a href="pyad2.html#pyad2.ad2.Overseer.DetectThread">Overseer.DetectThread (class in pyad2.ad2)</a>
</dt>

</dl></td> </dl></td>
</tr></table> </tr></table>


@@ -614,7 +614,7 @@
</dt> </dt>


<dt><a href="pyad2.html#pyad2.ad2.Overseer.DetectThread.run">run() (pyad2.ad2.Overseer.DetectThread method)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.DetectThread.run">run() (pyad2.ad2.AD2Factory.DetectThread method)</a>
</dt> </dt>


<dd><dl> <dd><dl>
@@ -692,7 +692,7 @@
</dt> </dt>


<dt><a href="pyad2.html#pyad2.ad2.Overseer.start">start() (pyad2.ad2.Overseer method)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.start">start() (pyad2.ad2.AD2Factory method)</a>
</dt> </dt>


@@ -700,12 +700,12 @@
</dt> </dt>


<dt><a href="pyad2.html#pyad2.ad2.Overseer.stop">stop() (pyad2.ad2.Overseer method)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.stop">stop() (pyad2.ad2.AD2Factory method)</a>
</dt> </dt>


<dd><dl> <dd><dl>
<dt><a href="pyad2.html#pyad2.ad2.Overseer.DetectThread.stop">(pyad2.ad2.Overseer.DetectThread method)</a>
<dt><a href="pyad2.html#pyad2.ad2.AD2Factory.DetectThread.stop">(pyad2.ad2.AD2Factory.DetectThread method)</a>
</dt> </dt>




BIN
docs/_build/html/objects.inv View File


+ 16
- 3
docs/_build/html/pyad2.event.html View File

@@ -23,7 +23,9 @@
<script type="text/javascript" src="_static/jquery.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/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="pyad2 documentation" href="index.html" />
<link rel="top" title="pyad2 documentation" href="index.html" />
<link rel="up" title="pyad2 Package" href="pyad2.html" />
<link rel="prev" title="pyad2 Package" href="pyad2.html" />
</head> </head>
<body> <body>
<div class="related"> <div class="related">
@@ -35,7 +37,11 @@
<li class="right" > <li class="right" >
<a href="py-modindex.html" title="Python Module Index" <a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li> >modules</a> |</li>
<li><a href="index.html">pyad2 documentation</a> &raquo;</li>
<li class="right" >
<a href="pyad2.html" title="pyad2 Package"
accesskey="P">previous</a> |</li>
<li><a href="index.html">pyad2 documentation</a> &raquo;</li>
<li><a href="pyad2.html" accesskey="U">pyad2 Package</a> &raquo;</li>
</ul> </ul>
</div> </div>


@@ -104,6 +110,9 @@ e.fire(earg).</p>
</li> </li>
</ul> </ul>


<h4>Previous topic</h4>
<p class="topless"><a href="pyad2.html"
title="previous chapter">pyad2 Package</a></p>
<h3>This Page</h3> <h3>This Page</h3>
<ul class="this-page-menu"> <ul class="this-page-menu">
<li><a href="_sources/pyad2.event.txt" <li><a href="_sources/pyad2.event.txt"
@@ -135,7 +144,11 @@ e.fire(earg).</p>
<li class="right" > <li class="right" >
<a href="py-modindex.html" title="Python Module Index" <a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li> >modules</a> |</li>
<li><a href="index.html">pyad2 documentation</a> &raquo;</li>
<li class="right" >
<a href="pyad2.html" title="pyad2 Package"
>previous</a> |</li>
<li><a href="index.html">pyad2 documentation</a> &raquo;</li>
<li><a href="pyad2.html" >pyad2 Package</a> &raquo;</li>
</ul> </ul>
</div> </div>
<div class="footer"> <div class="footer">


+ 57
- 55
docs/_build/html/pyad2.html View File

@@ -56,27 +56,27 @@
<h1>pyad2 Package<a class="headerlink" href="#pyad2-package" title="Permalink to this headline">¶</a></h1> <h1>pyad2 Package<a class="headerlink" href="#pyad2-package" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-pyad2.ad2"> <div class="section" id="module-pyad2.ad2">
<span id="ad2-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">ad2</span></tt> Module<a class="headerlink" href="#module-pyad2.ad2" title="Permalink to this headline">¶</a></h2> <span id="ad2-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">ad2</span></tt> Module<a class="headerlink" href="#module-pyad2.ad2" title="Permalink to this headline">¶</a></h2>
<p>Provides the full AD2USB class and factory.</p>
<p>Provides the full AD2 class and factory.</p>
<dl class="class"> <dl class="class">
<dt id="pyad2.ad2.Overseer">
<em class="property">class </em><tt class="descclassname">pyad2.ad2.</tt><tt class="descname">Overseer</tt><big>(</big><em>attached_event=None</em>, <em>detached_event=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory">
<em class="property">class </em><tt class="descclassname">pyad2.ad2.</tt><tt class="descname">AD2Factory</tt><big>(</big><em>attached_event=None</em>, <em>detached_event=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Factory for creation of AD2USB devices as well as provides attach/detach events.&#8221;</p> <p>Factory for creation of AD2USB devices as well as provides attach/detach events.&#8221;</p>
<dl class="attribute"> <dl class="attribute">
<dt id="pyad2.ad2.Overseer.on_attached">
<tt class="descname">on_attached</tt><a class="headerlink" href="#pyad2.ad2.Overseer.on_attached" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.on_attached">
<tt class="descname">on_attached</tt><a class="headerlink" href="#pyad2.ad2.AD2Factory.on_attached" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when an AD2USB device has been detected.</p> <dd><p>Called when an AD2USB device has been detected.</p>
</dd></dl> </dd></dl>


<dl class="attribute"> <dl class="attribute">
<dt id="pyad2.ad2.Overseer.on_detached">
<tt class="descname">on_detached</tt><a class="headerlink" href="#pyad2.ad2.Overseer.on_detached" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.on_detached">
<tt class="descname">on_detached</tt><a class="headerlink" href="#pyad2.ad2.AD2Factory.on_detached" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when an AD2USB device has been removed.</p> <dd><p>Called when an AD2USB device has been removed.</p>
</dd></dl> </dd></dl>


<dl class="classmethod"> <dl class="classmethod">
<dt id="pyad2.ad2.Overseer.find_all">
<em class="property">classmethod </em><tt class="descname">find_all</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.find_all"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.find_all" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.find_all">
<em class="property">classmethod </em><tt class="descname">find_all</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.find_all"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.find_all" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all AD2USB devices located on the system.</p> <dd><p>Returns all AD2USB devices located on the system.</p>
<table class="docutils field-list" frame="void" rules="none"> <table class="docutils field-list" frame="void" rules="none">
<col class="field-name" /> <col class="field-name" />
@@ -84,15 +84,15 @@
<tbody valign="top"> <tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">list of devices found</td> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">list of devices found</td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">util.CommError</td>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">CommError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</dd></dl> </dd></dl>


<dl class="classmethod"> <dl class="classmethod">
<dt id="pyad2.ad2.Overseer.devices">
<em class="property">classmethod </em><tt class="descname">devices</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.devices"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.devices" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.devices">
<em class="property">classmethod </em><tt class="descname">devices</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.devices"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.devices" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a cached list of AD2USB devices located on the system.</p> <dd><p>Returns a cached list of AD2USB devices located on the system.</p>
<table class="docutils field-list" frame="void" rules="none"> <table class="docutils field-list" frame="void" rules="none">
<col class="field-name" /> <col class="field-name" />
@@ -105,8 +105,8 @@
</dd></dl> </dd></dl>


<dl class="classmethod"> <dl class="classmethod">
<dt id="pyad2.ad2.Overseer.create">
<em class="property">classmethod </em><tt class="descname">create</tt><big>(</big><em>device=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.create"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.create" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.create">
<em class="property">classmethod </em><tt class="descname">create</tt><big>(</big><em>device=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.create"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.create" title="Permalink to this definition">¶</a></dt>
<dd><p>Factory method that returns the requested AD2USB device, or the first device.</p> <dd><p>Factory method that returns the requested AD2USB device, or the first device.</p>
<table class="docutils field-list" frame="void" rules="none"> <table class="docutils field-list" frame="void" rules="none">
<col class="field-name" /> <col class="field-name" />
@@ -116,33 +116,33 @@
</tr> </tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">AD2USB object utilizing the specified device.</td> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">AD2USB object utilizing the specified device.</td>
</tr> </tr>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body">util.NoDeviceError</td>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body">NoDeviceError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</dd></dl> </dd></dl>


<dl class="method"> <dl class="method">
<dt id="pyad2.ad2.Overseer.close">
<tt class="descname">close</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.close"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.close" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.close">
<tt class="descname">close</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.close"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Clean up and shut down.</p> <dd><p>Clean up and shut down.</p>
</dd></dl> </dd></dl>


<dl class="method"> <dl class="method">
<dt id="pyad2.ad2.Overseer.start">
<tt class="descname">start</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.start" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.start">
<tt class="descname">start</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.start" title="Permalink to this definition">¶</a></dt>
<dd><p>Starts the detection thread, if not already running.</p> <dd><p>Starts the detection thread, if not already running.</p>
</dd></dl> </dd></dl>


<dl class="method"> <dl class="method">
<dt id="pyad2.ad2.Overseer.stop">
<tt class="descname">stop</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.stop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.stop" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.stop">
<tt class="descname">stop</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.stop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.stop" title="Permalink to this definition">¶</a></dt>
<dd><p>Stops the detection thread.</p> <dd><p>Stops the detection thread.</p>
</dd></dl> </dd></dl>


<dl class="method"> <dl class="method">
<dt id="pyad2.ad2.Overseer.get_device">
<tt class="descname">get_device</tt><big>(</big><em>device=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.get_device"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.get_device" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.get_device">
<tt class="descname">get_device</tt><big>(</big><em>device=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.get_device"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.get_device" title="Permalink to this definition">¶</a></dt>
<dd><p>Factory method that returns the requested AD2USB device, or the first device.</p> <dd><p>Factory method that returns the requested AD2USB device, or the first device.</p>
<table class="docutils field-list" frame="void" rules="none"> <table class="docutils field-list" frame="void" rules="none">
<col class="field-name" /> <col class="field-name" />
@@ -155,19 +155,19 @@
</dd></dl> </dd></dl>


<dl class="class"> <dl class="class">
<dt id="pyad2.ad2.Overseer.DetectThread">
<em class="property">class </em><tt class="descname">DetectThread</tt><big>(</big><em>overseer</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.DetectThread"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.DetectThread" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.DetectThread">
<em class="property">class </em><tt class="descname">DetectThread</tt><big>(</big><em>factory</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.DetectThread"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.DetectThread" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">threading.Thread</span></tt></p> <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">threading.Thread</span></tt></p>
<p>Thread that handles detection of added/removed devices.</p> <p>Thread that handles detection of added/removed devices.</p>
<dl class="method"> <dl class="method">
<dt id="pyad2.ad2.Overseer.DetectThread.stop">
<tt class="descname">stop</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.DetectThread.stop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.DetectThread.stop" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.DetectThread.stop">
<tt class="descname">stop</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.DetectThread.stop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.DetectThread.stop" title="Permalink to this definition">¶</a></dt>
<dd><p>Stops the thread.</p> <dd><p>Stops the thread.</p>
</dd></dl> </dd></dl>


<dl class="method"> <dl class="method">
<dt id="pyad2.ad2.Overseer.DetectThread.run">
<tt class="descname">run</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#Overseer.DetectThread.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.Overseer.DetectThread.run" title="Permalink to this definition">¶</a></dt>
<dt id="pyad2.ad2.AD2Factory.DetectThread.run">
<tt class="descname">run</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2Factory.DetectThread.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2Factory.DetectThread.run" title="Permalink to this definition">¶</a></dt>
<dd><p>The actual detection process.</p> <dd><p>The actual detection process.</p>
</dd></dl> </dd></dl>


@@ -179,7 +179,7 @@
<dt id="pyad2.ad2.AD2"> <dt id="pyad2.ad2.AD2">
<em class="property">class </em><tt class="descclassname">pyad2.ad2.</tt><tt class="descname">AD2</tt><big>(</big><em>device</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2" title="Permalink to this definition">¶</a></dt> <em class="property">class </em><tt class="descclassname">pyad2.ad2.</tt><tt class="descname">AD2</tt><big>(</big><em>device</em><big>)</big><a class="reference internal" href="_modules/pyad2/ad2.html#AD2"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>High-level wrapper around AD2USB/AD2SERIAL devices.</p>
<p>High-level wrapper around AD2 devices.</p>
<dl class="attribute"> <dl class="attribute">
<dt id="pyad2.ad2.AD2.on_arm"> <dt id="pyad2.ad2.AD2.on_arm">
<tt class="descname">on_arm</tt><a class="headerlink" href="#pyad2.ad2.AD2.on_arm" title="Permalink to this definition">¶</a></dt> <tt class="descname">on_arm</tt><a class="headerlink" href="#pyad2.ad2.AD2.on_arm" title="Permalink to this definition">¶</a></dt>
@@ -339,7 +339,7 @@
<dl class="attribute"> <dl class="attribute">
<dt id="pyad2.ad2.AD2.id"> <dt id="pyad2.ad2.AD2.id">
<tt class="descname">id</tt><a class="reference internal" href="_modules/pyad2/ad2.html#AD2.id"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2.id" title="Permalink to this definition">¶</a></dt> <tt class="descname">id</tt><a class="reference internal" href="_modules/pyad2/ad2.html#AD2.id"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.ad2.AD2.id" title="Permalink to this definition">¶</a></dt>
<dd><p>The ID of the AD2USB device.</p>
<dd><p>The ID of the AD2 device.</p>
<table class="docutils field-list" frame="void" rules="none"> <table class="docutils field-list" frame="void" rules="none">
<col class="field-name" /> <col class="field-name" />
<col class="field-body" /> <col class="field-body" />
@@ -436,12 +436,12 @@
</div> </div>
<div class="section" id="module-pyad2.devices"> <div class="section" id="module-pyad2.devices">
<span id="devices-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">devices</span></tt> Module<a class="headerlink" href="#module-pyad2.devices" title="Permalink to this headline">¶</a></h2> <span id="devices-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">devices</span></tt> Module<a class="headerlink" href="#module-pyad2.devices" title="Permalink to this headline">¶</a></h2>
<p>Contains different types of devices belonging to the AD2USB family.</p>
<p>Contains different types of devices belonging to the AD2 family.</p>
<dl class="class"> <dl class="class">
<dt id="pyad2.devices.Device"> <dt id="pyad2.devices.Device">
<em class="property">class </em><tt class="descclassname">pyad2.devices.</tt><tt class="descname">Device</tt><a class="reference internal" href="_modules/pyad2/devices.html#Device"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.devices.Device" title="Permalink to this definition">¶</a></dt> <em class="property">class </em><tt class="descclassname">pyad2.devices.</tt><tt class="descname">Device</tt><a class="reference internal" href="_modules/pyad2/devices.html#Device"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.devices.Device" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Generic parent device to all AD2USB products.</p>
<p>Generic parent device to all AD2 products.</p>
<dl class="attribute"> <dl class="attribute">
<dt id="pyad2.devices.Device.on_open"> <dt id="pyad2.devices.Device.on_open">
<tt class="descname">on_open</tt><a class="headerlink" href="#pyad2.devices.Device.on_open" title="Permalink to this definition">¶</a></dt> <tt class="descname">on_open</tt><a class="headerlink" href="#pyad2.devices.Device.on_open" title="Permalink to this definition">¶</a></dt>
@@ -566,7 +566,7 @@
<tbody valign="top"> <tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">list of devices</td> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">list of devices</td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">util.CommError</td>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">CommError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -628,7 +628,7 @@
</ul> </ul>
</td> </td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">util.NoDeviceError</p>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">NoDeviceError</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -651,7 +651,7 @@
<tbody valign="top"> <tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>str</em>) &#8211; Data to write</td> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>str</em>) &#8211; Data to write</td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">util.CommError</td>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">CommError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -667,7 +667,7 @@
<tbody valign="top"> <tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The character read from the device.</td> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The character read from the device.</td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">util.CommError</td>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">CommError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -690,7 +690,7 @@
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The line that was read.</p> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The line that was read.</p>
</td> </td>
</tr> </tr>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">util.CommError, util.TimeoutError</p>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">CommError, TimeoutError</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -722,7 +722,7 @@
</tr> </tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">list of devices</td> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">list of devices</td>
</tr> </tr>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body">util.CommError</td>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body">CommError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -756,7 +756,7 @@
</ul> </ul>
</td> </td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">util.NoDeviceError</p>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">NoDeviceError</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -779,7 +779,7 @@
<tbody valign="top"> <tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>str</em>) &#8211; The data to write.</td> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>str</em>) &#8211; The data to write.</td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">util.CommError</td>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">CommError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -795,7 +795,7 @@
<tbody valign="top"> <tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The character read from the device.</td> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The character read from the device.</td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">util.CommError</td>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">CommError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -818,7 +818,7 @@
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The line read.</p> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The line read.</p>
</td> </td>
</tr> </tr>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">util.CommError, util.TimeoutError</p>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">CommError, TimeoutError</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -831,7 +831,7 @@
<dt id="pyad2.devices.SocketDevice"> <dt id="pyad2.devices.SocketDevice">
<em class="property">class </em><tt class="descclassname">pyad2.devices.</tt><tt class="descname">SocketDevice</tt><big>(</big><em>interface=('localhost'</em>, <em>10000)</em><big>)</big><a class="reference internal" href="_modules/pyad2/devices.html#SocketDevice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.devices.SocketDevice" title="Permalink to this definition">¶</a></dt> <em class="property">class </em><tt class="descclassname">pyad2.devices.</tt><tt class="descname">SocketDevice</tt><big>(</big><em>interface=('localhost'</em>, <em>10000)</em><big>)</big><a class="reference internal" href="_modules/pyad2/devices.html#SocketDevice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.devices.SocketDevice" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#pyad2.devices.Device" title="pyad2.devices.Device"><tt class="xref py py-class docutils literal"><span class="pre">pyad2.devices.Device</span></tt></a></p> <dd><p>Bases: <a class="reference internal" href="#pyad2.devices.Device" title="pyad2.devices.Device"><tt class="xref py py-class docutils literal"><span class="pre">pyad2.devices.Device</span></tt></a></p>
<p>Device that supports communication with an AD2USB that is exposed via ser2sock or another
<p>Device that supports communication with an AD2 that is exposed via ser2sock or another
Serial to IP interface.</p> Serial to IP interface.</p>
<dl class="attribute"> <dl class="attribute">
<dt id="pyad2.devices.SocketDevice.interface"> <dt id="pyad2.devices.SocketDevice.interface">
@@ -917,7 +917,7 @@ Serial to IP interface.</p>
</ul> </ul>
</td> </td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">util.NoDeviceError, util.CommError</p>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">NoDeviceError, CommError</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -942,7 +942,7 @@ Serial to IP interface.</p>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The number of bytes sent.</td> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The number of bytes sent.</td>
</tr> </tr>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body">util.CommError</td>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body">CommError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -958,7 +958,7 @@ Serial to IP interface.</p>
<tbody valign="top"> <tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The character read from the device.</td> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The character read from the device.</td>
</tr> </tr>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">util.CommError</td>
<tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body">CommError</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -981,7 +981,7 @@ Serial to IP interface.</p>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The line read from the device.</p> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The line read from the device.</p>
</td> </td>
</tr> </tr>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">util.CommError, util.TimeoutError</p>
<tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last">CommError, TimeoutError</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -993,7 +993,7 @@ Serial to IP interface.</p>
</div> </div>
<div class="section" id="module-pyad2.util"> <div class="section" id="module-pyad2.util">
<span id="util-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">util</span></tt> Module<a class="headerlink" href="#module-pyad2.util" title="Permalink to this headline">¶</a></h2> <span id="util-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">util</span></tt> Module<a class="headerlink" href="#module-pyad2.util" title="Permalink to this headline">¶</a></h2>
<p>Provides utility classes for the AD2USB devices.</p>
<p>Provides utility classes for the AD2 devices.</p>
<dl class="exception"> <dl class="exception">
<dt id="pyad2.util.NoDeviceError"> <dt id="pyad2.util.NoDeviceError">
<em class="property">exception </em><tt class="descclassname">pyad2.util.</tt><tt class="descname">NoDeviceError</tt><a class="reference internal" href="_modules/pyad2/util.html#NoDeviceError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.util.NoDeviceError" title="Permalink to this definition">¶</a></dt> <em class="property">exception </em><tt class="descclassname">pyad2.util.</tt><tt class="descname">NoDeviceError</tt><a class="reference internal" href="_modules/pyad2/util.html#NoDeviceError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.util.NoDeviceError" title="Permalink to this definition">¶</a></dt>
@@ -1026,7 +1026,7 @@ Serial to IP interface.</p>
<dt id="pyad2.util.Firmware"> <dt id="pyad2.util.Firmware">
<em class="property">class </em><tt class="descclassname">pyad2.util.</tt><tt class="descname">Firmware</tt><a class="reference internal" href="_modules/pyad2/util.html#Firmware"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.util.Firmware" title="Permalink to this definition">¶</a></dt> <em class="property">class </em><tt class="descclassname">pyad2.util.</tt><tt class="descname">Firmware</tt><a class="reference internal" href="_modules/pyad2/util.html#Firmware"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.util.Firmware" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Represents firmware for the AD2USB/AD2SERIAL devices.</p>
<p>Represents firmware for the AD2 devices.</p>
<dl class="attribute"> <dl class="attribute">
<dt id="pyad2.util.Firmware.STAGE_START"> <dt id="pyad2.util.Firmware.STAGE_START">
<tt class="descname">STAGE_START</tt><em class="property"> = 0</em><a class="headerlink" href="#pyad2.util.Firmware.STAGE_START" title="Permalink to this definition">¶</a></dt> <tt class="descname">STAGE_START</tt><em class="property"> = 0</em><a class="headerlink" href="#pyad2.util.Firmware.STAGE_START" title="Permalink to this definition">¶</a></dt>
@@ -1060,7 +1060,7 @@ Serial to IP interface.</p>
<dl class="staticmethod"> <dl class="staticmethod">
<dt id="pyad2.util.Firmware.upload"> <dt id="pyad2.util.Firmware.upload">
<em class="property">static </em><tt class="descname">upload</tt><big>(</big><em>dev</em>, <em>filename</em>, <em>progress_callback=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/util.html#Firmware.upload"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.util.Firmware.upload" title="Permalink to this definition">¶</a></dt> <em class="property">static </em><tt class="descname">upload</tt><big>(</big><em>dev</em>, <em>filename</em>, <em>progress_callback=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/util.html#Firmware.upload"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.util.Firmware.upload" title="Permalink to this definition">¶</a></dt>
<dd><p>Uploads firmware to an AD2USB/AD2SERIAL device.</p>
<dd><p>Uploads firmware to an AD2 device.</p>
<table class="docutils field-list" frame="void" rules="none"> <table class="docutils field-list" frame="void" rules="none">
<col class="field-name" /> <col class="field-name" />
<col class="field-body" /> <col class="field-body" />
@@ -1083,7 +1083,7 @@ Serial to IP interface.</p>
</div> </div>
<div class="section" id="module-pyad2.zonetracking"> <div class="section" id="module-pyad2.zonetracking">
<span id="zonetracking-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">zonetracking</span></tt> Module<a class="headerlink" href="#module-pyad2.zonetracking" title="Permalink to this headline">¶</a></h2> <span id="zonetracking-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">zonetracking</span></tt> Module<a class="headerlink" href="#module-pyad2.zonetracking" title="Permalink to this headline">¶</a></h2>
<p>Provides zone tracking functionality for the AD2USB device family.</p>
<p>Provides zone tracking functionality for the AD2 device family.</p>
<dl class="class"> <dl class="class">
<dt id="pyad2.zonetracking.Zone"> <dt id="pyad2.zonetracking.Zone">
<em class="property">class </em><tt class="descclassname">pyad2.zonetracking.</tt><tt class="descname">Zone</tt><big>(</big><em>zone=0</em>, <em>name=''</em>, <em>status=0</em><big>)</big><a class="reference internal" href="_modules/pyad2/zonetracking.html#Zone"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.zonetracking.Zone" title="Permalink to this definition">¶</a></dt> <em class="property">class </em><tt class="descclassname">pyad2.zonetracking.</tt><tt class="descname">Zone</tt><big>(</big><em>zone=0</em>, <em>name=''</em>, <em>status=0</em><big>)</big><a class="reference internal" href="_modules/pyad2/zonetracking.html#Zone"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.zonetracking.Zone" title="Permalink to this definition">¶</a></dt>
@@ -1160,7 +1160,7 @@ Serial to IP interface.</p>
</div> </div>
<div class="section" id="module-pyad2.messages"> <div class="section" id="module-pyad2.messages">
<span id="messages-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">messages</span></tt> Module<a class="headerlink" href="#module-pyad2.messages" title="Permalink to this headline">¶</a></h2> <span id="messages-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">messages</span></tt> Module<a class="headerlink" href="#module-pyad2.messages" title="Permalink to this headline">¶</a></h2>
<p>Message representations received from the panel through the AD2USB.</p>
<p>Message representations received from the panel through the AD2 devices.</p>
<dl class="class"> <dl class="class">
<dt id="pyad2.messages.BaseMessage"> <dt id="pyad2.messages.BaseMessage">
<em class="property">class </em><tt class="descclassname">pyad2.messages.</tt><tt class="descname">BaseMessage</tt><a class="reference internal" href="_modules/pyad2/messages.html#BaseMessage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.messages.BaseMessage" title="Permalink to this definition">¶</a></dt> <em class="property">class </em><tt class="descclassname">pyad2.messages.</tt><tt class="descname">BaseMessage</tt><a class="reference internal" href="_modules/pyad2/messages.html#BaseMessage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.messages.BaseMessage" title="Permalink to this definition">¶</a></dt>
@@ -1183,12 +1183,14 @@ Serial to IP interface.</p>
<dl class="attribute"> <dl class="attribute">
<dt id="pyad2.messages.ExpanderMessage.ZONE"> <dt id="pyad2.messages.ExpanderMessage.ZONE">
<tt class="descname">ZONE</tt><em class="property"> = 0</em><a class="headerlink" href="#pyad2.messages.ExpanderMessage.ZONE" title="Permalink to this definition">¶</a></dt> <tt class="descname">ZONE</tt><em class="property"> = 0</em><a class="headerlink" href="#pyad2.messages.ExpanderMessage.ZONE" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dd><p>Flag indicating that the expander message relates to a Zone Expander.</p>
</dd></dl>


<dl class="attribute"> <dl class="attribute">
<dt id="pyad2.messages.ExpanderMessage.RELAY"> <dt id="pyad2.messages.ExpanderMessage.RELAY">
<tt class="descname">RELAY</tt><em class="property"> = 1</em><a class="headerlink" href="#pyad2.messages.ExpanderMessage.RELAY" title="Permalink to this definition">¶</a></dt> <tt class="descname">RELAY</tt><em class="property"> = 1</em><a class="headerlink" href="#pyad2.messages.ExpanderMessage.RELAY" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dd><p>Flag indicating that the expander message relates to a Relay Expander.</p>
</dd></dl>


</dd></dl> </dd></dl>




+ 0
- 146
docs/_build/html/pyad2usb.event.html View File

@@ -1,146 +0,0 @@
<!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="Content-Type" content="text/html; charset=utf-8" />
<title>event Package &mdash; pyad2 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</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>
<link rel="top" title="pyad2 documentation" href="index.html" />
</head>
<body>
<div class="related">
<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><a href="index.html">pyad2 documentation</a> &raquo;</li>
</ul>
</div>

<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="event-package">
<h1>event Package<a class="headerlink" href="#event-package" title="Permalink to this headline">¶</a></h1>
<div class="section" id="id1">
<h2><tt class="xref py py-mod docutils literal"><span class="pre">event</span></tt> Package<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<span class="target" id="module-pyad2.event"></span></div>
<div class="section" id="module-pyad2.event.event">
<span id="event-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">event</span></tt> Module<a class="headerlink" href="#module-pyad2.event.event" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="pyad2.event.event.Event">
<em class="property">class </em><tt class="descclassname">pyad2.event.event.</tt><tt class="descname">Event</tt><big>(</big><em>doc=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/event/event.html#Event"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.event.event.Event" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
</dd></dl>

<dl class="class">
<dt id="pyad2.event.event.EventHandler">
<em class="property">class </em><tt class="descclassname">pyad2.event.event.</tt><tt class="descname">EventHandler</tt><big>(</big><em>event</em>, <em>obj</em><big>)</big><a class="reference internal" href="_modules/pyad2/event/event.html#EventHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.event.event.EventHandler" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<dl class="method">
<dt id="pyad2.event.event.EventHandler.add">
<tt class="descname">add</tt><big>(</big><em>func</em><big>)</big><a class="reference internal" href="_modules/pyad2/event/event.html#EventHandler.add"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.event.event.EventHandler.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add new event handler function.</p>
<p>Event handler function must be defined like func(sender, earg).
You can add handler also by using &#8216;+=&#8217; operator.</p>
</dd></dl>

<dl class="method">
<dt id="pyad2.event.event.EventHandler.remove">
<tt class="descname">remove</tt><big>(</big><em>func</em><big>)</big><a class="reference internal" href="_modules/pyad2/event/event.html#EventHandler.remove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.event.event.EventHandler.remove" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove existing event handler function.</p>
<p>You can remove handler also by using &#8216;-=&#8217; operator.</p>
</dd></dl>

<dl class="method">
<dt id="pyad2.event.event.EventHandler.fire">
<tt class="descname">fire</tt><big>(</big><em>earg=None</em><big>)</big><a class="reference internal" href="_modules/pyad2/event/event.html#EventHandler.fire"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyad2.event.event.EventHandler.fire" title="Permalink to this definition">¶</a></dt>
<dd><p>Fire event and call all handler functions</p>
<p>You can call EventHandler object itself like e(earg) instead of
e.fire(earg).</p>
</dd></dl>

</dd></dl>

</div>
</div>


</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">event Package</a><ul>
<li><a class="reference internal" href="#id1"><tt class="docutils literal"><span class="pre">event</span></tt> Package</a></li>
<li><a class="reference internal" href="#module-pyad2.event.event"><tt class="docutils literal"><span class="pre">event</span></tt> Module</a></li>
</ul>
</li>
</ul>

<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/pyad2usb.event.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<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>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<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><a href="index.html">pyad2 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Author.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2b1.
</div>
</body>
</html>

+ 0
- 1277
docs/_build/html/pyad2usb.html
File diff suppressed because it is too large
View File


+ 1
- 1
docs/_build/html/searchindex.js
File diff suppressed because it is too large
View File


+ 0
- 37
docs/_build/text/index.txt View File

@@ -1,37 +0,0 @@

Welcome to pyad2's documentation!
*********************************

Contents:

* pyad2 Package

* "ad2" Module

* "devices" Module

* "util" Module

* "zonetracking" Module

* "panels" Module

* "messages" Module

* Subpackages

* event Package

* "event" Package

* "event" Module


Indices and tables
******************

* *Index*

* *Module Index*

* *Search Page*

+ 0
- 25
docs/_build/text/modules.txt View File

@@ -1,25 +0,0 @@

pyad2
*****

* pyad2 Package

* "ad2" Module

* "devices" Module

* "util" Module

* "zonetracking" Module

* "panels" Module

* "messages" Module

* Subpackages

* event Package

* "event" Package

* "event" Module

+ 0
- 39
docs/_build/text/pyad2.event.txt View File

@@ -1,39 +0,0 @@

event Package
*************


"event" Package
===============


"event" Module
==============

class class pyad2.event.event.Event(doc=None)

Bases: "object"

class class pyad2.event.event.EventHandler(event, obj)

Bases: "object"

add(func)

Add new event handler function.

Event handler function must be defined like func(sender, earg).
You can add handler also by using '+=' operator.

remove(func)

Remove existing event handler function.

You can remove handler also by using '-=' operator.

fire(earg=None)

Fire event and call all handler functions

You can call EventHandler object itself like e(earg) instead of
e.fire(earg).

+ 0
- 784
docs/_build/text/pyad2.txt View File

@@ -1,784 +0,0 @@

pyad2 Package
*************


"ad2" Module
============

Provides the full AD2USB class and factory.

class class pyad2.ad2.Overseer(attached_event=None, detached_event=None)

Bases: "object"

Factory for creation of AD2USB devices as well as provides
attach/detach events."

on_attached

Called when an AD2USB device has been detected.

on_detached

Called when an AD2USB device has been removed.

classmethod find_all()

Returns all AD2USB devices located on the system.

Returns:
list of devices found

Raises :
util.CommError

classmethod devices()

Returns a cached list of AD2USB devices located on the system.

Returns:
cached list of devices found.

classmethod create(device=None)

Factory method that returns the requested AD2USB device, or the
first device.

Parameters:
**device** (*tuple*) -- Tuple describing the USB device to
open, as returned by find_all().

Returns:
AD2USB object utilizing the specified device.

Raises :
util.NoDeviceError

close()

Clean up and shut down.

start()

Starts the detection thread, if not already running.

stop()

Stops the detection thread.

get_device(device=None)

Factory method that returns the requested AD2USB device, or the
first device.

Parameters:
**device** (*tuple*) -- Tuple describing the USB device to
open, as returned by find_all().

class class DetectThread(overseer)

Bases: "threading.Thread"

Thread that handles detection of added/removed devices.

stop()

Stops the thread.

run()

The actual detection process.

class class pyad2.ad2.AD2(device)

Bases: "object"

High-level wrapper around AD2USB/AD2SERIAL devices.

on_arm

Called when the panel is armed.

on_disarm

Called when the panel is disarmed.

on_power_changed

Called when panel power switches between AC and DC.

on_alarm

Called when the alarm is triggered.

on_fire

Called when a fire is detected.

on_bypass

Called when a zone is bypassed.

on_boot

Called when the device finishes bootings.

on_config_received

Called when the device receives its configuration.

on_zone_fault

Called when the device detects a zone fault.

on_zone_restore

Called when the device detects that a fault is restored.

on_low_battery

Called when the device detects a low battery.

on_panic

Called when the device detects a panic.

on_relay_changed

Called when a relay is opened or closed on an expander board.

on_message

Called when a message has been received from the device.

on_lrr_message

Called when an LRR message is received.

on_rfx_message

Called when an RFX message is received.

on_open

Called when the device has been opened.

on_close

Called when the device has been closed.

on_read

Called when a line has been read from the device.

on_write

Called when data has been written to the device.

F1 = u'\x01\x01\x01'

Represents panel function key #1

F2 = u'\x02\x02\x02'

Represents panel function key #2

F3 = u'\x03\x03\x03'

Represents panel function key #3

F4 = u'\x04\x04\x04'

Represents panel function key #4

BATTERY_TIMEOUT = 30

Timeout before the battery status reverts.

FIRE_TIMEOUT = 30

Timeout before the fire status reverts.

id

The ID of the AD2USB device.

Returns:
The identification string for the device.

open(baudrate=None, no_reader_thread=False)

Opens the device.

Parameters:
* **baudrate** (*int*) -- The baudrate used for the device.

* **interface** (*varies depends on device type.. FIXME*)
-- The interface used for the device.

* **index** (*int*) -- Interface index.. can probably
remove. FIXME

* **no_reader_thread** (*bool*) -- Specifies whether or not
the automatic reader thread should be started or not

close()

Closes the device.

send(data)

get_config()

Retrieves the configuration from the device.

save_config()

Sets configuration entries on the device.

reboot()

Reboots the device.

fault_zone(zone, simulate_wire_problem=False)

Faults a zone if we are emulating a zone expander.

Parameters:
* **zone** (*int*) -- The zone to fault.

* **simulate_wire_problem** (*bool*) -- Whether or not to
simulate a wire fault.

clear_zone(zone)

Clears a zone if we are emulating a zone expander.

Parameters:
**zone** (*int*) -- The zone to clear.


"devices" Module
================

Contains different types of devices belonging to the AD2USB family.

class class pyad2.devices.Device

Bases: "object"

Generic parent device to all AD2USB products.

on_open

Called when the device has been opened

on_close

Called when the device has been closed

on_read

Called when a line has been read from the device

on_write

Called when data has been written to the device

id

Retrieve the device ID.

Returns:
The identification string for the device.

is_reader_alive()

Indicates whether or not the reader thread is alive.

Returns:
Whether or not the reader thread is alive.

stop_reader()

Stops the reader thread.

close()

Closes the device.

class class ReadThread(device)

Bases: "threading.Thread"

Reader thread which processes messages from the device.

READ_TIMEOUT = 10

Timeout for the reader thread.

stop()

Stops the running thread.

run()

The actual read process.

class class pyad2.devices.USBDevice(interface=(None, 0))

Bases: "pyad2.devices.Device"

AD2USB device exposed with PyFTDI's interface.

FTDI_VENDOR_ID = 1027

Vendor ID used to recognize AD2USB devices.

FTDI_PRODUCT_ID = 24577

Product ID used to recognize AD2USB devices.

BAUDRATE = 115200

Default baudrate for AD2USB devices.

static find_all()

Returns all FTDI devices matching our vendor and product IDs.

Returns:
list of devices

Raises :
util.CommError

interface

Retrieves the interface used to connect to the device.

Returns:
the interface used to connect to the device.

serial_number

Retrieves the serial number of the device.

Returns:
The serial number of the device.

description

Retrieves the description of the device.

Returns:
The description of the device.

open(baudrate=115200, no_reader_thread=False)

Opens the device.

Parameters:
* **baudrate** (*int*) -- The baudrate to use.

* **no_reader_thread** (*bool*) -- Whether or not to
automatically start the reader thread.

Raises :
util.NoDeviceError

close()

Closes the device.

write(data)

Writes data to the device.

Parameters:
**data** (*str*) -- Data to write

Raises :
util.CommError

read()

Reads a single character from the device.

Returns:
The character read from the device.

Raises :
util.CommError

read_line(timeout=0.0, purge_buffer=False)

Reads a line from the device.

Parameters:
* **timeout** (*float*) -- Read timeout

* **purge_buffer** (*bool*) -- Indicates whether to purge
the buffer prior to reading.

Returns:
The line that was read.

Raises :
util.CommError, util.TimeoutError

class class pyad2.devices.SerialDevice(interface=None)

Bases: "pyad2.devices.Device"

AD2USB or AD2SERIAL device exposed with the pyserial interface.

BAUDRATE = 19200

Default baudrate for Serial devices.

static find_all(pattern=None)

Returns all serial ports present.

Parameters:
**pattern** (*str*) -- Pattern to search for when retrieving
serial ports.

Returns:
list of devices

Raises :
util.CommError

interface

Retrieves the interface used to connect to the device.

Returns:
the interface used to connect to the device.

open(baudrate=19200, no_reader_thread=False)

Opens the device.

Parameters:
* **baudrate** (*int*) -- The baudrate to use with the
device.

* **no_reader_thread** (*bool*) -- Whether or not to
automatically start the reader thread.

Raises :
util.NoDeviceError

close()

Closes the device.

write(data)

Writes data to the device.

Parameters:
**data** (*str*) -- The data to write.

Raises :
util.CommError

read()

Reads a single character from the device.

Returns:
The character read from the device.

Raises :
util.CommError

read_line(timeout=0.0, purge_buffer=False)

Reads a line from the device.

Parameters:
* **timeout** (*float*) -- The read timeout.

* **purge_buffer** (*bool*) -- Indicates whether to purge
the buffer prior to reading.

Returns:
The line read.

Raises :
util.CommError, util.TimeoutError

class class pyad2.devices.SocketDevice(interface=('localhost', 10000))

Bases: "pyad2.devices.Device"

Device that supports communication with an AD2USB that is exposed
via ser2sock or another Serial to IP interface.

interface

Retrieves the interface used to connect to the device.

Returns:
the interface used to connect to the device.

ssl

Retrieves whether or not the device is using SSL.

Returns:
Whether or not the device is using SSL.

ssl_certificate

Retrieves the SSL client certificate path used for
authentication.

Returns:
The certificate path

ssl_key

Retrieves the SSL client certificate key used for
authentication.

Returns:
The key path

ssl_ca

Retrieves the SSL Certificate Authority certificate used for
authentication.

Returns:
The CA path

open(baudrate=None, no_reader_thread=False)

Opens the device.

Parameters:
* **baudrate** (*int*) -- The baudrate to use

* **no_reader_thread** (*bool*) -- Whether or not to
automatically open the reader thread.

Raises :
util.NoDeviceError, util.CommError

close()

Closes the device.

write(data)

Writes data to the device.

Parameters:
**data** (*str*) -- The data to write.

Returns:
The number of bytes sent.

Raises :
util.CommError

read()

Reads a single character from the device.

Returns:
The character read from the device.

Raises :
util.CommError

read_line(timeout=0.0, purge_buffer=False)

Reads a line from the device.

Parameters:
* **timeout** (*float*) -- The read timeout.

* **purge_buffer** (*bool*) -- Indicates whether to purge
the buffer prior to reading.

Returns:
The line read from the device.

Raises :
util.CommError, util.TimeoutError


"util" Module
=============

Provides utility classes for the AD2USB devices.

exception exception pyad2.util.NoDeviceError

Bases: "exceptions.Exception"

No devices found.

exception exception pyad2.util.CommError

Bases: "exceptions.Exception"

There was an error communicating with the device.

exception exception pyad2.util.TimeoutError

Bases: "exceptions.Exception"

There was a timeout while trying to communicate with the device.

exception exception pyad2.util.InvalidMessageError

Bases: "exceptions.Exception"

The format of the panel message was invalid.

class class pyad2.util.Firmware

Bases: "object"

Represents firmware for the AD2USB/AD2SERIAL devices.

STAGE_START = 0

STAGE_WAITING = 1

STAGE_BOOT = 2

STAGE_LOAD = 3

STAGE_UPLOADING = 4

STAGE_DONE = 5

static upload(dev, filename, progress_callback=None)

Uploads firmware to an AD2USB/AD2SERIAL device.

Parameters:
* **filename** (*str*) -- The firmware filename

* **progress_callback** (*function*) -- Callback function
used to report progress.

Raises :
util.NoDeviceError, util.TimeoutError


"zonetracking" Module
=====================

Provides zone tracking functionality for the AD2USB device family.

class class pyad2.zonetracking.Zone(zone=0, name='', status=0)

Bases: "object"

Representation of a panel zone.

CLEAR = 0

Status indicating that the zone is cleared.

FAULT = 1

Status indicating that the zone is faulted.

CHECK = 2

Status indicating that there is a wiring issue with the zone.

STATUS = {0: 'CLEAR', 1: 'FAULT', 2: 'CHECK'}

class class pyad2.zonetracking.Zonetracker

Bases: "object"

Handles tracking of zone and their statuses.

on_fault

Called when the device detects a zone fault.

on_restore

Called when the device detects that a fault is restored.

EXPIRE = 30

Zone expiration timeout.

update(message)

Update zone statuses based on the current message.

Parameters:
**message** (*Message or ExpanderMessage*) -- Message to use
to update the zone tracking.


"panels" Module
===============

Representations of Panels and their templates.


"messages" Module
=================

Message representations received from the panel through the AD2USB.

class class pyad2.messages.BaseMessage

Bases: "object"

Base class for messages.

class class pyad2.messages.Message(data=None)

Bases: "pyad2.messages.BaseMessage"

Represents a message from the alarm panel.

class class pyad2.messages.ExpanderMessage(data=None)

Bases: "pyad2.messages.BaseMessage"

Represents a message from a zone or relay expansion module.

ZONE = 0

RELAY = 1

class class pyad2.messages.RFMessage(data=None)

Bases: "pyad2.messages.BaseMessage"

Represents a message from an RF receiver.

class class pyad2.messages.LRRMessage(data=None)

Bases: "pyad2.messages.BaseMessage"

Represent a message from a Long Range Radio.


Subpackages
===========

* event Package

* "event" Package

* "event" Module

+ 1
- 1
pyad2/zonetracking.py View File

@@ -1,5 +1,5 @@
""" """
Provides zone tracking functionality for the AD2USB device family.
Provides zone tracking functionality for the AD2 device family.


.. moduleauthor:: Scott Petersen <scott@nutech.com> .. moduleauthor:: Scott Petersen <scott@nutech.com>
""" """


+ 1
- 1
setup.py View File

@@ -17,7 +17,7 @@ setup(name='pyad2',
'Topic :: Home Automation', 'Topic :: Home Automation',
'Topic :: Security', 'Topic :: Security',
], ],
keywords='alarm data ad2usb ad2serial ad2pi security ademco dsc',
keywords='alarm data ad2 ad2usb ad2serial ad2pi security ademco dsc',
url='http://github.com/nutechsoftware/pyad2', url='http://github.com/nutechsoftware/pyad2',
author='Nu Tech Software Solutions, Inc.', author='Nu Tech Software Solutions, Inc.',
author_email='general@support.nutech.com', author_email='general@support.nutech.com',


Loading…
Cancel
Save