Skip to content

Commit

Permalink
docs: Update to use module diretive
Browse files Browse the repository at this point in the history
Update the documentation to indicated which module each class is located
without affecting the naming conventions.
This allows the documentation to be referenced from other modules as
well as enabling links to the source code directly from the
documentation.
  • Loading branch information
marcbonnici committed Dec 19, 2019
1 parent 2650a53 commit c0f44fd
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 183 deletions.
38 changes: 24 additions & 14 deletions doc/connection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ Connection

A :class:`Connection` abstracts an actual physical connection to a device. The
first connection is created when :func:`Target.connect` method is called. If a
:class:`Target` is used in a multi-threaded environment, it will maintain a
connection for each thread in which it is invoked. This allows the same target
object to be used in parallel in multiple threads.
:class:`~devlib.target.Target` is used in a multi-threaded environment, it will
maintain a connection for each thread in which it is invoked. This allows
the same target object to be used in parallel in multiple threads.

:class:`Connection`\ s will be automatically created and managed by
:class:`Target`\ s, so there is usually no reason to create one manually.
Instead, configuration for a :class:`Connection` is passed as
`connection_settings` parameter when creating a :class:`Target`. The connection
to be used target is also specified on instantiation by `conn_cls` parameter,
though all concrete :class:`Target` implementations will set an appropriate
:class:`~devlib.target.Target`\ s, so there is usually no reason to create one
manually. Instead, configuration for a :class:`Connection` is passed as
`connection_settings` parameter when creating a
:class:`~devlib.target.Target`. The connection to be used target is also
specified on instantiation by `conn_cls` parameter, though all concrete
:class:`~devlib.target.Target` implementations will set an appropriate
default, so there is typically no need to specify this explicitly.

:class:`Connection` classes are not a part of an inheritance hierarchy, i.e.
Expand Down Expand Up @@ -76,7 +77,7 @@ class that implements the following methods.

.. note:: This **will block the connection** until the command completes.

.. note:: The above methods are directly wrapped by :class:`Target` methods,
.. note:: The above methods are directly wrapped by :class:`~devlib.target.Target` methods,
however note that some of the defaults are different.

.. method:: cancel_running_command(self)
Expand All @@ -95,11 +96,15 @@ class that implements the following methods.
opened on instantiation.



.. _connection-types:

Connection Types
----------------


.. module:: devlib.utils.android

.. class:: AdbConnection(device=None, timeout=None, adb_server=None, adb_as_root=False)

A connection to an android device via ``adb`` (Android Debug Bridge).
Expand All @@ -116,6 +121,7 @@ Connection Types
:param adb_server: Allows specifying the address of the adb server to use.
:param adb_as_root: Specify whether the adb server should be restarted in root mode.

.. module:: devlib.utils.ssh

.. class:: SshConnection(host, username, password=None, keyfile=None, port=None,\
timeout=None, password_prompt=None, \
Expand Down Expand Up @@ -178,6 +184,7 @@ Connection Types
connection to reduce the possibility of clashes).
This parameter is ignored for SSH connections.

.. module:: devlib.host

.. class:: LocalConnection(keep_password=True, unrooted=False, password=None)

Expand All @@ -193,6 +200,9 @@ Connection Types
prompting for it.


.. module:: devlib.utils.ssh
:noindex:

.. class:: Gem5Connection(platform, host=None, username=None, password=None,\
timeout=None, password_prompt=None,\
original_prompt=None)
Expand All @@ -211,7 +221,7 @@ Connection Types
will be ignored, the gem5 simulation needs to be
on the same host the user is currently on, so if
the host given as input parameter is not the
same as the actual host, a ``TargetStableError``
same as the actual host, a :class:`TargetStableError`
will be raised to prevent confusion.

:param username: Username in the simulated system
Expand All @@ -237,14 +247,14 @@ The only methods discussed below are those that will be overwritten by the

A connection to a gem5 simulation that emulates a Linux system.

.. method:: _login_to_device(self)
.. method:: _login_to_device(self)

Login to the gem5 simulated system.
Login to the gem5 simulated system.

.. class:: AndroidGem5Connection

A connection to a gem5 simulation that emulates an Android system.

.. method:: _wait_for_boot(self)
.. method:: _wait_for_boot(self)

Wait for the gem5 simulated system to have booted and finished the booting animation.
Wait for the gem5 simulated system to have booted and finished the booting animation.
24 changes: 15 additions & 9 deletions doc/derived_measurements.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Derived Measurements
=====================


The ``DerivedMeasurements`` API provides a consistent way of performing post
processing on a provided :class:`MeasurementCsv` file.

Expand Down Expand Up @@ -35,6 +34,8 @@ API
Derived Measurements
~~~~~~~~~~~~~~~~~~~~

.. module:: devlib.derived

.. class:: DerivedMeasurements

The ``DerivedMeasurements`` class provides an API for post-processing
Expand Down Expand Up @@ -102,17 +103,20 @@ Available Derived Measurements
Energy
~~~~~~

.. module:: devlib.derived.energy

.. class:: DerivedEnergyMeasurements

The ``DerivedEnergyMeasurements`` class is used to calculate average power and
cumulative energy for each site if the required data is present.
The ``DerivedEnergyMeasurements`` class is used to calculate average power
and cumulative energy for each site if the required data is present.

The calculation of cumulative energy can occur in 3 ways. If a
``site`` contains ``energy`` results, the first and last measurements are extracted
and the delta calculated. If not, a ``timestamp`` channel will be used to calculate
the energy from the power channel, failing back to using the sample rate attribute
of the :class:`MeasurementCsv` file if timestamps are not available. If neither
timestamps or a sample rate are available then an error will be raised.
The calculation of cumulative energy can occur in 3 ways. If a ``site``
contains ``energy`` results, the first and last measurements are extracted
and the delta calculated. If not, a ``timestamp`` channel will be used to
calculate the energy from the power channel, failing back to using the sample
rate attribute of the :class:`MeasurementCsv` file if timestamps are not
available. If neither timestamps or a sample rate are available then an error
will be raised.


.. method:: DerivedEnergyMeasurements.process(measurement_csv)
Expand All @@ -128,6 +132,8 @@ Energy
FPS / Rendering
~~~~~~~~~~~~~~~

.. module:: devlib.derived.fps

.. class:: DerivedGfxInfoStats(drop_threshold=5, suffix='-fps', filename=None, outdir=None)

Produces FPS (frames-per-second) and other derived statistics from
Expand Down
53 changes: 32 additions & 21 deletions doc/instrumentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Instrumentation

The ``Instrument`` API provide a consistent way of collecting measurements from
a target. Measurements are collected via an instance of a class derived from
:class:`Instrument`. An ``Instrument`` allows collection of measurement from one
or more channels. An ``Instrument`` may support ``INSTANTANEOUS`` or
``CONTINUOUS`` collection, or both.
:class:`~devlib.instrument.Instrument`. An ``Instrument`` allows collection of
measurement from one or more channels. An ``Instrument`` may support
``INSTANTANEOUS`` or ``CONTINUOUS`` collection, or both.

Example
-------
Expand Down Expand Up @@ -48,6 +48,8 @@ Android target.
API
---

.. module:: devlib.instrument

Instrument
~~~~~~~~~~

Expand Down Expand Up @@ -120,22 +122,25 @@ Instrument
Take a single measurement from ``active_channels``. Returns a list of
:class:`Measurement` objects (one for each active channel).

.. note:: This method is only implemented by :class:`Instrument`\ s that
.. note:: This method is only implemented by
:class:`~devlib.instrument.Instrument`\ s that
support ``INSTANTANEOUS`` measurement.

.. method:: Instrument.start()

Starts collecting measurements from ``active_channels``.

.. note:: This method is only implemented by :class:`Instrument`\ s that
.. note:: This method is only implemented by
:class:`~devlib.instrument.Instrument`\ s that
support ``CONTINUOUS`` measurement.

.. method:: Instrument.stop()

Stops collecting measurements from ``active_channels``. Must be called after
:func:`start()`.

.. note:: This method is only implemented by :class:`Instrument`\ s that
.. note:: This method is only implemented by
:class:`~devlib.instrument.Instrument`\ s that
support ``CONTINUOUS`` measurement.

.. method:: Instrument.get_data(outfile)
Expand All @@ -146,9 +151,9 @@ Instrument
``<site>_<kind>`` (see :class:`InstrumentChannel`). The order of the columns
will be the same as the order of channels in ``Instrument.active_channels``.

If reporting timestamps, one channel must have a ``site`` named ``"timestamp"``
and a ``kind`` of a :class:`MeasurmentType` of an appropriate time unit which will
be used, if appropriate, during any post processing.
If reporting timestamps, one channel must have a ``site`` named
``"timestamp"`` and a ``kind`` of a :class:`MeasurmentType` of an appropriate
time unit which will be used, if appropriate, during any post processing.

.. note:: Currently supported time units are seconds, milliseconds and
microseconds, other units can also be used if an appropriate
Expand All @@ -158,7 +163,8 @@ Instrument
that can be used to stream :class:`Measurement`\ s lists (similar to what is
returned by ``take_measurement()``.

.. note:: This method is only implemented by :class:`Instrument`\ s that
.. note:: This method is only implemented by
:class:`~devlib.instrument.Instrument`\ s that
support ``CONTINUOUS`` measurement.

.. method:: Instrument.get_raw()
Expand All @@ -183,7 +189,8 @@ Instrument

Sample rate of the instrument in Hz. Assumed to be the same for all channels.

.. note:: This attribute is only provided by :class:`Instrument`\ s that
.. note:: This attribute is only provided by
:class:`~devlib.instrument.Instrument`\ s that
support ``CONTINUOUS`` measurement.

Instrument Channel
Expand All @@ -192,8 +199,8 @@ Instrument Channel
.. class:: InstrumentChannel(name, site, measurement_type, \*\*attrs)

An :class:`InstrumentChannel` describes a single type of measurement that may
be collected by an :class:`Instrument`. A channel is primarily defined by a
``site`` and a ``measurement_type``.
be collected by an :class:`~devlib.instrument.Instrument`. A channel is
primarily defined by a ``site`` and a ``measurement_type``.

A ``site`` indicates where on the target a measurement is collected from
(e.g. a voltage rail or location of a sensor).
Expand Down Expand Up @@ -486,12 +493,13 @@ voltage (see previous figure), samples are retrieved at a frequency of
where :math:`T_X` is the integration time for the :math:`X` voltage.

As described below (:meth:`BaylibreAcmeInstrument.reset`), the integration
times for the bus and shunt voltage can be set separately which allows a
tradeoff of accuracy between signals. This is particularly useful as the shunt
voltage returned by the INA226 has a higher resolution than the bus voltage
(2.5 μV and 1.25 mV LSB, respectively) and therefore would benefit more from a
longer integration time.
As described below (:meth:`BaylibreAcmeInstrument.reset
<devlib.instrument.baylibre_acme.BaylibreAcmeInstrument.reset>`), the
integration times for the bus and shunt voltage can be set separately which
allows a tradeoff of accuracy between signals. This is particularly useful as
the shunt voltage returned by the INA226 has a higher resolution than the bus
voltage (2.5 μV and 1.25 mV LSB, respectively) and therefore would benefit more
from a longer integration time.

As an illustration, consider the following sampled sine wave and notice how
increasing the integration time (of the bus voltage in this case) "smoothes"
Expand Down Expand Up @@ -599,8 +607,9 @@ Buffer-based transactions

Samples made available by the INA226 are retrieved by the BBB and stored in a
buffer which is sent back to the host once it is full (see
``buffer_samples_count`` in :meth:`BaylibreAcmeInstrument.setup` for setting
its size). Therefore, the larger the buffer is, the longer it takes to be
``buffer_samples_count`` in :meth:`BaylibreAcmeInstrument.setup
<devlib.instrument.baylibre_acme.BaylibreAcmeInstrument.setup>` for setting its
size). Therefore, the larger the buffer is, the longer it takes to be
transmitted back but the less often it has to be transmitted. To illustrate
this, consider the following graphs showing the time difference between
successive samples in a retrieved signal when the size of the buffer changes:
Expand All @@ -622,6 +631,8 @@ given by `libiio (the Linux IIO interface)`_ however only the network-based one
has been tested. For the other classes, please refer to the official IIO
documentation for the meaning of their constructor parameters.

.. module:: devlib.instrument.baylibre_acme

.. class:: BaylibreAcmeInstrument(target=None, iio_context=None, use_base_iio_context=False, probe_names=None)

Base class wrapper for the ACME instrument which itself is a wrapper for the
Expand Down

0 comments on commit c0f44fd

Please sign in to comment.