Lab-Measurement
view release on metacpan or search on metacpan
lib/Lab/Moose/Sweep/Continuous.pm view on Meta::CPAN
package Lab::Moose::Sweep::Continuous;
$Lab::Moose::Sweep::Continuous::VERSION = '3.931';
#ABSTRACT: Base class for continuous sweeps (time, temperature, magnetic field)
use v5.20;
use Moose;
use MooseX::Params::Validate;
# Do not import all functions as they clash with the attribute methods.
use Lab::Moose 'linspace';
use Time::HiRes qw/time sleep/;
use Carp;
extends 'Lab::Moose::Sweep';
#
# Public attributes set by the user
#
has instrument =>
( is => 'ro', isa => 'Lab::Moose::Instrument', required => 1 );
has from => ( is => 'ro', isa => 'Num' );
has to => ( is => 'ro', isa => 'Num' );
has rate => ( is => 'ro', isa => 'Lab::Moose::PosNum' );
has start_rate => ( is => 'ro', isa => 'Lab::Moose::PosNum' );
has interval => ( is => 'ro', isa => 'Lab::Moose::PosNum' );
has points => (
is => 'ro', isa => 'ArrayRef[Num]', traits => ['Array'],
handles => {
get_point => 'get', num_points => 'count', points_array => 'elements'
},
writer => '_points',
);
has intervals => (
is => 'ro',
isa => 'ArrayRef[Num]',
traits => ['Array'],
handles => {
get_interval => 'get', num_intervals => 'count',
intervals_array => 'elements',
},
writer => '_intervals',
);
has rates => (
is => 'ro', isa => 'ArrayRef[Num]', traits => ['Array'],
handles => {
get_rate => 'get', num_rates => 'count', rates_array => 'elements'
},
writer => '_rates',
);
has backsweep => ( is => 'ro', isa => 'Bool', default => 0 );
has both_directions => ( is => 'ro', isa => 'Bool', default => 0 );
has direction_index => ( is => 'ro', isa => 'Int', default => 1 );
#
# Private attributes used internally
#
has points_index => (
is => 'ro', isa => 'Int', default => 0, init_arg => undef,
traits => ['Counter'],
handles => { inc_points_index => 'inc', reset_points_index => 'reset' },
);
# index for timing measurement sub
has index => (
is => 'ro', isa => 'Int', default => 0, init_arg => undef,
traits => ['Counter'],
handles => { inc_index => 'inc', reset_index => 'reset' }
);
has start_time =>
( is => 'ro', isa => 'Num', init_arg => undef, writer => '_start_time' );
# has in_backsweep => (
# is => 'ro', isa => 'Bool', init_arg => undef,
# writer => '_in_backsweep'
# );
sub _validate_points_attributes {
my $self = shift;
my $error_str
= "use either (points, rates, [intervals]) or (from, to, rate, [interval], [start_rate]) attributes";
if ( defined $self->points ) {
if ( not defined $self->rates ) {
croak "missing 'rates' attribute";
}
if ( defined $self->from
or defined $self->to
or defined $self->rate
or defined $self->start_rate
or $self->interval ) {
croak $error_str;
}
}
elsif ( defined $self->from ) {
if ( not defined $self->to ) {
croak "missing 'to' attribute";
}
if ( not defined $self->rate ) {
( run in 0.964 second using v1.01-cache-2.11-cpan-39bf76dae61 )