NAME

Lab::Moose::Instrument::AdjustRange - Role for automatic adjustment of measurement ranges.

VERSION

version 3.803

DESCRIPTION

This role provides the 'adjust_measurement_range' method, which selects a measurement range suitable for the current input signal.

METHODS

adjust_measurement_range

my $value = $instrument->get_value();
my $old_range = $instrument->adjust_measurement_range(
    value => $value,
    verbose => 1,
);
my $new_range = $instrument->get_range();

To limit the allowed ranges, supply an arrayref with allowed ranges:

$instrument->adjust_measurement_range(
    value => ...,
    allowed_ranges => [0.1, 10],
);

If verbose is set, carp whenever the measurement range is changed.

By default, the range is changed, whenever the signal exceeds 100% of the measurement range, this factor can be adjusted with the safety_factor attribute.

$instrument->adjust_measurement_range(
    ...,
    ...,
    safety_factor => 0.8, # change range when signal is at 80% of current range
);

REQUIRED METHODS

allowed_ranges

Arrayref with allowed ranges

set_range

$instrument->set_range(value => $new_range);

Set measurement range.

get_range

$instrument->get_cached_range();

Get current range from cache.

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by the Lab::Measurement team; in detail:

Copyright 2018       Simon Reinhardt
          2020       Andreas K. Huettel

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.