| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Lab::Moose::Instrument::SCPI::Sense::Frequency; | 
| 2 |  |  |  |  |  |  | $Lab::Moose::Instrument::SCPI::Sense::Frequency::VERSION = '3.881'; | 
| 3 |  |  |  |  |  |  | #ABSTRACT: Role for the SCPI SENSe:FREQuency subsystem | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 4 |  |  | 4 |  | 2208 | use v5.20; | 
|  | 4 |  |  |  |  | 19 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 4 |  |  | 4 |  | 47 | use Moose::Role; | 
|  | 4 |  |  |  |  | 8 |  | 
|  | 4 |  |  |  |  | 27 |  | 
| 8 | 4 |  |  | 4 |  | 19000 | use Lab::Moose::Instrument::Cache; | 
|  | 4 |  |  |  |  | 9 |  | 
|  | 4 |  |  |  |  | 32 |  | 
| 9 |  |  |  |  |  |  | use Lab::Moose::Instrument | 
| 10 | 4 |  |  | 4 |  | 2207 | qw/validated_channel_getter validated_channel_setter/; | 
|  | 4 |  |  |  |  | 10 |  | 
|  | 4 |  |  |  |  | 207 |  | 
| 11 | 4 |  |  | 4 |  | 25 | use MooseX::Params::Validate; | 
|  | 4 |  |  |  |  | 13 |  | 
|  | 4 |  |  |  |  | 24 |  | 
| 12 | 4 |  |  | 4 |  | 1771 | use Carp; | 
|  | 4 |  |  |  |  | 13 |  | 
|  | 4 |  |  |  |  | 201 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 4 |  |  | 4 |  | 33 | use namespace::autoclean; | 
|  | 4 |  |  |  |  | 13 |  | 
|  | 4 |  |  |  |  | 21 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | with 'Lab::Moose::Instrument::SCPI::Sense::Sweep'; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | cache sense_frequency_start => ( getter => 'sense_frequency_start_query' ); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | sub sense_frequency_start_query { | 
| 22 | 6 |  |  | 6 | 1 | 1779 | my ( $self, $channel, %args ) = validated_channel_getter( \@_ ); | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 6 |  |  |  |  | 54 | return $self->cached_sense_frequency_start( | 
| 25 |  |  |  |  |  |  | $self->query( command => "SENS${channel}:FREQ:STAR?", %args ) ); | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub sense_frequency_start { | 
| 29 | 4 |  |  | 4 | 1 | 17545 | my ( $self, $channel, $value, %args ) = validated_channel_setter( \@_ ); | 
| 30 | 4 |  |  |  |  | 67 | $self->write( | 
| 31 |  |  |  |  |  |  | command => sprintf( "SENS%s:FREQ:STAR %.17g", $channel, $value ), | 
| 32 |  |  |  |  |  |  | %args | 
| 33 |  |  |  |  |  |  | ); | 
| 34 | 4 |  |  |  |  | 24 | $self->cached_sense_frequency_start($value); | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | cache sense_frequency_stop => ( getter => 'sense_frequency_stop_query' ); | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub sense_frequency_stop_query { | 
| 40 | 6 |  |  | 6 | 1 | 1687 | my ( $self, $channel, %args ) = validated_channel_getter( \@_ ); | 
| 41 |  |  |  |  |  |  |  | 
| 42 | 6 |  |  |  |  | 43 | return $self->cached_sense_frequency_stop( | 
| 43 |  |  |  |  |  |  | $self->query( command => "SENS${channel}:FREQ:STOP?", %args ) ); | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | sub sense_frequency_stop { | 
| 47 | 4 |  |  | 4 | 1 | 6737 | my ( $self, $channel, $value, %args ) = validated_channel_setter( \@_ ); | 
| 48 | 4 |  |  |  |  | 58 | $self->write( | 
| 49 |  |  |  |  |  |  | command => sprintf( "SENS%s:FREQ:STOP %.17g", $channel, $value ), | 
| 50 |  |  |  |  |  |  | %args | 
| 51 |  |  |  |  |  |  | ); | 
| 52 | 4 |  |  |  |  | 24 | $self->cached_sense_frequency_stop($value); | 
| 53 |  |  |  |  |  |  | } | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | sub sense_frequency_linear_array { | 
| 57 | 9 |  |  | 9 | 1 | 39 | my ( $self, $channel, %args ) = validated_channel_getter( \@_ ); | 
| 58 |  |  |  |  |  |  |  | 
| 59 | 9 |  |  |  |  | 34 | my $start      = $self->cached_sense_frequency_start(); | 
| 60 | 9 |  |  |  |  | 38 | my $stop       = $self->cached_sense_frequency_stop(); | 
| 61 | 9 |  |  |  |  | 29 | my $num_points = $self->cached_sense_sweep_points(); | 
| 62 |  |  |  |  |  |  |  | 
| 63 | 9 |  |  |  |  | 30 | my $num_intervals = $num_points - 1; | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 9 | 50 |  |  |  | 27 | if ( $num_intervals == 0 ) { | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | # Return a single point. | 
| 68 | 0 |  |  |  |  | 0 | return [$start]; | 
| 69 |  |  |  |  |  |  | } | 
| 70 |  |  |  |  |  |  |  | 
| 71 | 9 |  |  |  |  | 34 | my @result; | 
| 72 |  |  |  |  |  |  |  | 
| 73 | 9 |  |  |  |  | 28 | for my $i ( 0 .. $num_intervals ) { | 
| 74 | 321 |  |  |  |  | 467 | my $f = $start + ( $stop - $start ) * ( $i / $num_intervals ); | 
| 75 | 321 |  |  |  |  | 466 | push @result, $f; | 
| 76 |  |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 9 |  |  |  |  | 34 | return \@result; | 
| 79 |  |  |  |  |  |  | } | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | 1; | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | __END__ | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =pod | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | =encoding UTF-8 | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head1 NAME | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | Lab::Moose::Instrument::SCPI::Sense::Frequency - Role for the SCPI SENSe:FREQuency subsystem | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | =head1 VERSION | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | version 3.881 | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | =head1 METHODS | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | =head2 sense_frequency_start_query | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | my $freq = $self->sense_frequency_start_query(); | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | Query the starting point of the frequency sweep. | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | =head2 sense_frequency_start | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | $self->sense_frequency_start(value => 4e9); | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | Set the starting point of the frequency sweep. | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | =head2 sense_frequency_stop_query | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =head2 sense_frequency_stop | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | Query and set the end point of the frequency sweep. | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | =head2 sense_frequency_linear_array | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | my $arrayref = $self->sense_frequency_linear_array(); | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | Helper method to get an arrayref of all points in the frequency sweep. | 
| 122 |  |  |  |  |  |  | Does not provide a cached form, but will read it's input from cache. | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | This software is copyright (c) 2023 by the Lab::Measurement team; in detail: | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | Copyright 2016       Simon Reinhardt | 
| 129 |  |  |  |  |  |  | 2017       Andreas K. Huettel, Simon Reinhardt | 
| 130 |  |  |  |  |  |  | 2018       Eugeniy E. Mikhailov | 
| 131 |  |  |  |  |  |  | 2020       Andreas K. Huettel | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 135 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | =cut |