Moose/Instrument/RS_SMB.pm

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