| 1 | package Lab::Moose::Instrument::SCPI::Sense::Frequency; | ||||||||||
| 2 | 4 | $Lab::Moose::Instrument::SCPI::Sense::Frequency::VERSION = '3.931'; | |||||||||
| 3 | #ABSTRACT: Role for the SCPI SENSe:FREQuency subsystem | ||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use v5.20; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 4 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 4 | ▶ | use Lab::Moose::Instrument::Cache; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | use Lab::Moose::Instrument | ||||||||||
| 10 | 4 | ▶ | qw/validated_channel_getter validated_channel_setter/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 4 | ▶ | use MooseX::Params::Validate; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 4 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 4 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 4 | with 'Lab::Moose::Instrument::SCPI::Sense::Sweep'; | |||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | 4 | cache sense_frequency_start => ( getter => 'sense_frequency_start_query' ); | |||||||||
| 20 | |||||||||||
| 21 | 6 | ▶ | sub sense_frequency_start_query { | ||||||||
|
Subroutine
sense_frequency_start_query: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 6 | my ( $self, $channel, %args ) = validated_channel_getter( \@_ ); | |||||||||
| 23 | |||||||||||
| 24 | 6 | return $self->cached_sense_frequency_start( | |||||||||
| 25 | $self->query( command => "SENS${channel}:FREQ:STAR?", %args ) ); | ||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 4 | ▶ | sub sense_frequency_start { | ||||||||
|
Subroutine
sense_frequency_start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 29 | 4 | my ( $self, $channel, $value, %args ) = validated_channel_setter( \@_ ); | |||||||||
| 30 | 4 | $self->write( | |||||||||
| 31 | command => sprintf( "SENS%s:FREQ:STAR %.17g", $channel, $value ), | ||||||||||
| 32 | %args | ||||||||||
| 33 | ); | ||||||||||
| 34 | 4 | $self->cached_sense_frequency_start($value); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 4 | cache sense_frequency_stop => ( getter => 'sense_frequency_stop_query' ); | |||||||||
| 38 | |||||||||||
| 39 | 6 | ▶ | sub sense_frequency_stop_query { | ||||||||
|
Subroutine
sense_frequency_stop_query: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 40 | 6 | my ( $self, $channel, %args ) = validated_channel_getter( \@_ ); | |||||||||
| 41 | |||||||||||
| 42 | 6 | return $self->cached_sense_frequency_stop( | |||||||||
| 43 | $self->query( command => "SENS${channel}:FREQ:STOP?", %args ) ); | ||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 4 | ▶ | sub sense_frequency_stop { | ||||||||
|
Subroutine
sense_frequency_stop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 47 | 4 | my ( $self, $channel, $value, %args ) = validated_channel_setter( \@_ ); | |||||||||
| 48 | 4 | $self->write( | |||||||||
| 49 | command => sprintf( "SENS%s:FREQ:STOP %.17g", $channel, $value ), | ||||||||||
| 50 | %args | ||||||||||
| 51 | ); | ||||||||||
| 52 | 4 | $self->cached_sense_frequency_stop($value); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | 9 | ▶ | sub sense_frequency_linear_array { | ||||||||
|
Subroutine
sense_frequency_linear_array: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||
| 57 | 9 | my ( $self, $channel, %args ) = validated_channel_getter( \@_ ); | |||||||||
| 58 | |||||||||||
| 59 | 9 | my $start = $self->cached_sense_frequency_start(); | |||||||||
| 60 | 9 | my $stop = $self->cached_sense_frequency_stop(); | |||||||||
| 61 | 9 | my $num_points = $self->cached_sense_sweep_points(); | |||||||||
| 62 | |||||||||||
| 63 | 9 | my $num_intervals = $num_points - 1; | |||||||||
| 64 | |||||||||||
| 65 | 9 | ▶ | if ( $num_intervals == 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | |||||||||||
| 67 | # Return a single point. | ||||||||||
| 68 | 0 | return [$start]; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 9 | my @result; | |||||||||
| 72 | |||||||||||
| 73 | 9 | for my $i ( 0 .. $num_intervals ) { | |||||||||
| 74 | 321 | my $f = $start + ( $stop - $start ) * ( $i / $num_intervals ); | |||||||||
| 75 | 321 | push @result, $f; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 9 | return \@result; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 4 | 1; | |||||||||
| 82 | |||||||||||
| 83 | __END__ | ||||||||||