Moose/Instrument/SCPI/Sense/Frequency.pm

filter: Statementstmt 97.8% 46 / 47 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 5 / 5 totaltotal 96.9% 64 / 66 SCAR 11.0
CC
3
Cov
96%
sense_frequency_linear_array
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« Moose/Instrument/Zhinst.pm ↑ Summary Moose/Instrument/TBS1000C.pm »
1 package Lab::Moose::Instrument::SCPI::Sense::Frequency;
2 4 $Lab::Moose::Instrument::SCPI::Sense::Frequency::VERSION = '3.881';
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 sub sense_frequency_start_query {
22 6 ▶ my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
Subroutine sense_frequency_start_query: called CC=1 SCAR=0.0
Pod documented
23  
24 6 return $self->cached_sense_frequency_start(
25 $self->query( command => "SENS${channel}:FREQ:STAR?", %args ) );
26 }
27  
28 sub sense_frequency_start {
29 4 ▶ my ( $self, $channel, $value, %args ) = validated_channel_setter( \@_ );
Subroutine sense_frequency_start: called CC=1 SCAR=0.0
Pod documented
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 sub sense_frequency_stop_query {
40 6 ▶ my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
Subroutine sense_frequency_stop_query: called CC=1 SCAR=0.0
Pod documented
41  
42 6 return $self->cached_sense_frequency_stop(
43 $self->query( command => "SENS${channel}:FREQ:STOP?", %args ) );
44 }
45  
46 sub sense_frequency_stop {
47 4 ▶ my ( $self, $channel, $value, %args ) = validated_channel_setter( \@_ );
Subroutine sense_frequency_stop: called CC=1 SCAR=0.0
Pod documented
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 sub sense_frequency_linear_array {
57 9 ▶ my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
Subroutine sense_frequency_linear_array: called CC=3 SCAR=11.1
Pod documented
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
BranchTrueFalseTotal
if ($num_intervals == 0) 0 9 9
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__
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
« Moose/Instrument/Zhinst.pm ↑ Summary Moose/Instrument/TBS1000C.pm »