App-Device-Chip-sensor

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


      * --mid3, -m

      Enable "middle-of-3" filtering of gauge values, to reduce sensor
      noise from unreliable sensors. This is equivalent to setting -F mid3.

      * --best-effort, -B

      Enables best-effort mode, which causes failures of sensor readings to
      be ignored, reporting undef instead. In this mode, the on_sensor_fail
      method may be invoked for failures; it can further refine what the
      behaviour should be.

PROVIDED METHODS

    The following methods are provided on the base class, intended for
    subclasses or applications to invoke.

 parse_argv

       $app->parse_argv();
       $app->parse_argv( \@argv );

    Provides a list of commandline arguments for parsing, either from a
    given array reference or defaulting to the process @ARGV if not
    supplied.

    This uses "OPTSPEC" to collect the defined arguments, whose references
    should handle the results.

 add_chip

       $app->add_chip( %config );

    Since version 0.05.

    Adds a new chip to the stored configuration, as if it had been given as
    a commandline argument. Takes the following named arguments:

    type => STR

      Required string that gives the name of the chip class.

    adapter => Device::Chip::Adapter

      Required Device::Chip::Adapter instance.

    mountopts => HASH

      Optional HASH reference containing extra mount parameters.

    config => HASH

      Optional HASH reference containing extra chip configuration to set up
      using the configure method once mounted.

 chips

       @chips = await $app->chips;

    An asynchronous memoized lazy accessor for the list of Device::Chip
    instances, whose class names are taken from the remaining commandline
    arguments after the options are parsed.

 sensors

       @sensors = await $app->sensors;

    An asynchronous memoized lazy accessor for the list of
    Device::Chip::Sensor instances of each of the configured chips (from
    the "chips" method).

 run

       await $app->run;

    An asynchronous method which performs the actual run loop of the sensor
    application. This implements the main application logic, of regular
    collection of values from all of the sensor instances and reporting
    them to the "output_readings" method.

    In normal circumstances the Future instance returned by this method
    would remain pending for the lifetime of the program, and not complete.
    For an application that has nothing else to perform concurrently it can
    simply await this future to run the logic. If it has other logic to
    perform as well it could combine this with other futures using a
    Future->needs_all or similar techniques.

 print_readings

       $app->print_readings( $sensors, $values );

    Prints the sensor names and current readings in a human-readable format
    to the currently-selected output handle (usually STDOUT).

REQUIRED METHODS

    This base class itself is incomplete, requiring the following methods
    to be provided by an implementing subclass to contain the actual
    application logic.

 output_readings

       $app->output_readings( $now, $sensors, $values );

    This method is invoked regularly by the "run" method, to provide the
    application with the latest round of sensor readings. It is passed the
    current UNIX epoch timestamp as $now, an array reference containing the
    individual Device::Chip::Sensor instances as $sensors, and a congruent
    array reference containing the most recent readings taken from them, as
    plain numbers.

    The application should put the bulk of its processing logic in here,
    for example writing the values to some sort of file or database,
    displaying them in some form, or whatever else the application is
    supposed to do.

OVERRIDABLE METHODS

    The base class provides the following methods, but it is expected that
    applications may wish to override them to customise the logic contained
    in them.

    If using Object::Pad to do so, don't forget to provide the :override
    method attribute.

 OPTSPEC

       %optspec = $app->OPTSPEC;

    This method is invoked by the "parse_argv" method to construct a
    definition of the commandline options understood by the program. These
    are returned in a key/value list to be processed by Getopt::Long. If
    the application wishes to parse additional arguments it should override
    this method, call the superclass version, and append any extra argument
    specifications it requires.



( run in 1.051 second using v1.01-cache-2.11-cpan-39bf76dae61 )