App-Device-Chip-sensor

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    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.

    As this is invoked as a regular instance method, a convenient way to
    store the parsed values is to pass references to instance slot
    variables created by the Object::Pad field keyword:

       field $_title;
       field $_bgcol = "#cccccc";
    
       method OPTSPEC :override
       {
          return ( $self->SUPER::OPTSPEC,
             'title=s'            => \$_title,
             'background-color=s' => \$_bgcol,
          );
       }

 after_sensors

       await $app->after_sensors( @sensors );

    This method is invoked once on startup by the "run" method, after it
    has configured the chip adapter and chips and obtained their individual
    sensor instances. The application may wish to perform one-time startup
    tasks in here, such as creating database files with knowledge of the
    specific sensor data types, or other such behaviours.

 on_sensor_ok

       $app->on_sensor_ok( $sensor );

    This method is invoked in --best-effort mode after a successful reading
    from sensor; typically this is used to clear a failure state.

    The default implementation does nothing.

 on_sensor_fail

       $app->on_sensor_fail( $sensor, $failure );

    This method is invoked in --best-effort mode after a failure of the
    given sensor. The caught exception is passed as $failure.

    The default implementation prints this as a warning using the core
    warn() function.

FILTERING

    The --filter setting accepts the following filter names

 null

    No filtering is applied. Each sensor reading is reported as it stands.

 midn

    The most recent n values are sorted, and the middle of these is
    reported. To be well-behaved, n should be an odd number. (mid3, mid5,
    mid7, etc...)

 ravgn

    Recursive average with weighting of 2 ** -n.

AUTHOR

    Paul Evans <leonerd@leonerd.org.uk>



( run in 0.997 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )