Moose/Instrument/KeysightN9310A.pm

filter: Statementstmt 35.7% 30 / 84 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 26.6% 8 / 30 Podpod 18.1% 4 / 22 totaltotal 30.4% 42 / 138 CC 2 SCAR 6.9
CC
2
Cov
35%
source_frequency
6.0
BUILD
2.0
source_frequency_query
2.0
CRAP 2.0
« Moose/Instrument/HP3458A.pm ↑ Summary Moose/Instrument/TBS1000C.pm »
1 package Lab::Moose::Instrument::KeysightN9310A;
2 1 $Lab::Moose::Instrument::KeysightN9310A::VERSION = '3.931';
3 #ABSTRACT: Keysight N9310A Signal Generator
4  
5 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Lab::Moose::Instrument qw/validated_getter validated_setter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Lab::Moose::Instrument::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 extends 'Lab::Moose::Instrument';
17  
18  
19 #around default_connection_options => sub {
20 # my $orig = shift;
21 # my $self = shift;
22 # my $options = $self->$orig();
23 # my $usb_opts = { vid => 0x0aad, pid => 0x0054 };
24 # $options->{USB} = $usb_opts;
25 # $options->{'VISA::USB'} = $usb_opts;
26 # return $options;
27 #};
28  
29 1 with qw(
30 Lab::Moose::Instrument::Common
31  
32 Lab::Moose::Instrument::SCPI::Output::State
33 );
34  
35 0 ▶sub BUILD {
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
36 0 my $self = shift;
37 # $self->cls();
38 }
39  
40  
41  
42 1 cache source_frequency => ( getter => 'source_frequency_query' );
43  
44 0 ▶sub source_frequency_query {
Subroutine source_frequency_query: not called CC=1 SCAR=6.9
Pod undocumented
45 0 my ( $self, %args ) = validated_getter( \@_ );
46 0 return $self->cached_source_frequency(
47 $self->query( command => ":FREQuency:CW?", %args ) );
48 }
49  
50 0 ▶sub source_frequency {
Subroutine source_frequency: not called CC=2 SCAR=17.9
Pod undocumented
51 0 my ( $self, $value, %args ) = validated_setter(
52 \@_,
53 value => { isa => 'Num' },
54 );
55  
56 0 my $min_freq = 9e3;
57 0 ▶ if ( $value < $min_freq ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value < $min_freq) 0 0 0
58 0 croak "value smaller than minimal frequency $min_freq";
59 }
60  
61 0 $self->write( command => sprintf( ":FREQuency:CW %f MHz", ($value/1e6) ), %args );
62 0 $self->cached_source_frequency($value);
63 }
64  
65 1 cache source_power => ( getter => 'source_power_query' );
66  
67 0 ▶sub source_power_query {
Subroutine source_power_query: not called CC=1 SCAR=6.9
Pod undocumented
68 0 my ( $self, %args ) = validated_getter( \@_ );
69 0 return $self->cached_source_power(
70 $self->query( command => ":AMPLitude:CW?", %args ) );
71 }
72  
73 0 ▶sub source_power {
Subroutine source_power: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my ( $self, $value, %args ) = validated_setter(
75 \@_,
76 value => { isa => 'Num' },
77 );
78  
79 0 $self->write( command => sprintf( ":AMPLitude:CW %f dBm", $value ), %args );
80 0 $self->cached_source_power($value);
81 }
82  
83  
84  
85  
86 0 ▶sub set_power {
Subroutine set_power: not called CC=1 SCAR=6.9
Pod documented
87 0 my $self = shift;
88 0 return $self->source_power(@_);
89 }
90  
91 0 ▶sub get_power {
Subroutine get_power: not called CC=1 SCAR=6.9
Pod documented
92 0 my $self = shift;
93 0 return $self->source_power_query(@_);
94 }
95  
96 0 ▶sub cached_power {
Subroutine cached_power: not called CC=1 SCAR=6.9
Pod undocumented
97 0 my $self = shift;
98 0 return $self->cached_source_power(@_);
99 }
100  
101  
102  
103 0 ▶sub cached_frq {
Subroutine cached_frq: not called CC=1 SCAR=6.9
Pod undocumented
104 0 my $self = shift;
105 0 return $self->cached_source_frequency(@_);
106 }
107  
108 0 ▶sub set_frq {
Subroutine set_frq: not called CC=1 SCAR=6.9
Pod documented
109 0 my $self = shift;
110 0 return $self->source_frequency(@_);
111 }
112  
113 0 ▶sub get_frq {
Subroutine get_frq: not called CC=1 SCAR=6.9
Pod documented
114 0 my $self = shift;
115 0 return $self->source_frequency_query();
116 }
117  
118 #
119 # Pulse/AM modulation stuff from old RSSMB100A driver; TODO: caching + docs
120 #
121  
122 0 ▶sub set_pulselength {
Subroutine set_pulselength: not called CC=1 SCAR=6.9
Pod undocumented
123 0 my ( $self, $value, %args ) = validated_setter( \@_ );
124 0 $self->write( command => "PULM:WIDT $value s", %args );
125 }
126  
127 0 ▶sub get_pulselength {
Subroutine get_pulselength: not called CC=1 SCAR=6.9
Pod undocumented
128 0 my ( $self, %args ) = validated_getter( \@_ );
129 0 return $self->query( command => "PULM:WIDT?", %args );
130 }
131  
132 0 ▶sub set_pulseperiod {
Subroutine set_pulseperiod: not called CC=1 SCAR=6.9
Pod undocumented
133 0 my ( $self, $value, %args ) = validated_setter( \@_ );
134 0 $self->write( command => "PULM:PER $value s", %args );
135 }
136  
137 0 ▶sub get_pulseperiod {
Subroutine get_pulseperiod: not called CC=1 SCAR=6.9
Pod undocumented
138 0 my ( $self, %args ) = validated_getter( \@_ );
139 0 return $self->query( command => "PULM:PER?", %args );
140 }
141  
142 0 ▶sub selftest {
Subroutine selftest: not called CC=1 SCAR=6.9
Pod undocumented
143 0 my ( $self, %args ) = validated_getter( \@_ );
144 0 return $self->query( command => "*TST?", %args );
145 }
146  
147 0 ▶sub display_on {
Subroutine display_on: not called CC=1 SCAR=6.9
Pod undocumented
148 0 my ( $self, %args ) = validated_getter( \@_ );
149 0 $self->write( command => "DISPlay ON", %args );
150 }
151  
152 0 ▶sub display_off {
Subroutine display_off: not called CC=1 SCAR=6.9
Pod undocumented
153 0 my ( $self, %args ) = validated_getter( \@_ );
154 0 $self->write( command => "DISPlay OFF", %args );
155 }
156  
157 0 ▶sub enable_external_am {
Subroutine enable_external_am: not called CC=1 SCAR=6.9
Pod undocumented
158 0 my ( $self, %args ) = validated_getter( \@_ );
159 0 $self->write( command => "AM:DEPTh MAX", %args );
160 0 $self->write( command => "AM:SENSitivity 70PCT/VOLT", %args );
161 0 $self->write( command => "AM:TYPE LINear", %args );
162 0 $self->write( command => "AM:STATe ON", %args );
163 }
164  
165 0 ▶sub disable_external_am {
Subroutine disable_external_am: not called CC=1 SCAR=6.9
Pod undocumented
166 0 my ( $self, %args ) = validated_getter( \@_ );
167 0 $self->write( command => "AM:STATe OFF", %args );
168 }
169  
170 0 ▶sub enable_internal_pulsemod {
Subroutine enable_internal_pulsemod: not called CC=1 SCAR=6.9
Pod undocumented
171 0 my ( $self, %args ) = validated_getter( \@_ );
172 0 $self->write( command => "PULM:SOUR INT", %args );
173 0 $self->write( command => "PULM:DOUB:STAT OFF", %args );
174 0 $self->write( command => "PULM:MODE SING", %args );
175 0 $self->write( command => "PULM:STAT ON", %args );
176 }
177  
178 0 ▶sub disable_internal_pulsemod {
Subroutine disable_internal_pulsemod: not called CC=1 SCAR=6.9
Pod undocumented
179 0 my ( $self, %args ) = validated_getter( \@_ );
180 0 $self->write( command => "PULM:STAT OFF", %args );
181 }
182  
183 1 __PACKAGE__->meta()->make_immutable();
184  
185 1 1;
186  
187 __END__
« Moose/Instrument/HP3458A.pm ↑ Summary Moose/Instrument/TBS1000C.pm »