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 SCAR 8.8
CC
2
Cov
53%
source_frequency
2.1
set_power
2.0
get_power
2.0
CRAP 2.4
« XPRESS/Sweep/Dummy.pm ↑ Summary Instrument/Multimeter.pm »
1 package Lab::Moose::Instrument::RS_SMB;
2 2 $Lab::Moose::Instrument::RS_SMB::VERSION = '3.881';
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 around default_connection_options => sub {
19 1 ▶ my $orig = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
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 sub BUILD {
36 1 ▶ my $self = shift;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
37 1 $self->clear();
38 1 $self->cls();
39 }
40  
41  
42  
43 2 cache source_frequency => ( getter => 'source_frequency_query' );
44  
45 sub source_frequency_query {
46 3 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine source_frequency_query: called CC=1 SCAR=0.0
Pod undocumented
47 3 return $self->cached_source_frequency(
48 $self->query( command => "FREQ?", %args ) );
49 }
50  
51 sub source_frequency {
52 3 ▶ my ( $self, $value, %args ) = validated_setter(
Subroutine source_frequency: called CC=2 SCAR=7.2
Pod undocumented
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 sub set_power {
68 0 ▶ my $self = shift;
Subroutine set_power: not called CC=1 SCAR=6.9
Pod documented
69 0 return $self->source_power_level_immediate_amplitude(@_);
70 }
71  
72 sub get_power {
73 0 ▶ my $self = shift;
Subroutine get_power: not called CC=1 SCAR=6.9
Pod documented
74 0 return $self->source_power_level_immediate_amplitude_query(@_);
75 }
76  
77 sub cached_power {
78 0 ▶ my $self = shift;
Subroutine cached_power: not called CC=1 SCAR=6.9
Pod undocumented
79 0 return $self->cached_source_power_level_immediate_amplitude(@_);
80 }
81  
82  
83 sub cached_frq {
84 0 ▶ my $self = shift;
Subroutine cached_frq: not called CC=1 SCAR=6.9
Pod undocumented
85 0 return $self->cached_source_frequency(@_);
86 }
87  
88 #
89 # Aliases for Lab::XPRESS::Sweep API
90 #
91  
92 sub set_frq {
93 0 ▶ my $self = shift;
Subroutine set_frq: not called CC=1 SCAR=6.9
Pod documented
94 0 return $self->source_frequency(@_);
95 }
96  
97 sub get_frq {
98 0 ▶ my $self = shift;
Subroutine get_frq: not called CC=1 SCAR=6.9
Pod documented
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 sub set_pulselength {
107 0 ▶ my ( $self, $value, %args ) = validated_setter( \@_ );
Subroutine set_pulselength: not called CC=1 SCAR=6.9
Pod undocumented
108 0 $self->write( command => "PULM:WIDT $value s", %args );
109 }
110  
111 sub get_pulselength {
112 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_pulselength: not called CC=1 SCAR=6.9
Pod undocumented
113 0 return $self->query( command => "PULM:WIDT?", %args );
114 }
115  
116 sub set_pulseperiod {
117 0 ▶ my ( $self, $value, %args ) = validated_setter( \@_ );
Subroutine set_pulseperiod: not called CC=1 SCAR=6.9
Pod undocumented
118 0 $self->write( command => "PULM:PER $value s", %args );
119 }
120  
121 sub get_pulseperiod {
122 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine get_pulseperiod: not called CC=1 SCAR=6.9
Pod undocumented
123 0 return $self->query( command => "PULM:PER?", %args );
124 }
125  
126 sub selftest {
127 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine selftest: not called CC=1 SCAR=6.9
Pod undocumented
128 0 return $self->query( command => "*TST?", %args );
129 }
130  
131 sub display_on {
132 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine display_on: not called CC=1 SCAR=6.9
Pod undocumented
133 0 $self->write( command => "DISPlay ON", %args );
134 }
135  
136 sub display_off {
137 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine display_off: not called CC=1 SCAR=6.9
Pod undocumented
138 0 $self->write( command => "DISPlay OFF", %args );
139 }
140  
141 sub enable_external_am {
142 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine enable_external_am: not called CC=1 SCAR=6.9
Pod undocumented
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 sub disable_external_am {
150 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine disable_external_am: not called CC=1 SCAR=6.9
Pod undocumented
151 0 $self->write( command => "AM:STATe OFF", %args );
152 }
153  
154 sub enable_internal_pulsemod {
155 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine enable_internal_pulsemod: not called CC=1 SCAR=6.9
Pod undocumented
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 sub disable_internal_pulsemod {
163 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine disable_internal_pulsemod: not called CC=1 SCAR=6.9
Pod undocumented
164 0 $self->write( command => "PULM:STAT OFF", %args );
165 }
166  
167 2 __PACKAGE__->meta()->make_immutable();
168  
169 2 1;
170  
171 __END__
172  
173 =pod
174  
175 =encoding UTF-8
176  
177 =head1 NAME
178  
179 Lab::Moose::Instrument::RS_SMB - Rohde & Schwarz SMB Signal Generator
180  
181 =head1 VERSION
182  
183 version 3.881
184  
185 =head1 SYNOPSIS
186  
187 my $smb = instrument(
188 type => 'RS_SMB',
189 connection_type => 'VXI11',
190 connection_options => {host => '192.168.3.26'},
191 );
192
193 # Set frequency to 2 GHz
194 $smb->set_frq(value => 2e9);
195  
196 # Get frequency from device cache
197 my $frq = $smb->cached_frq();
198
199 # Set power to -10 dBm
200 $smb->set_power(value => -10);
201  
202 =head1 METHODS
203  
204 Used roles:
205  
206 =over
207  
208 =item L<Lab::Moose::Instrument::SCPI::Source::Power>
209  
210 =item L<Lab::Moose::Instrument::SCPI::Output::State>
211  
212 =back
213  
214 =head2 get_power/set_power
215  
216 $smb->set_power(value => -10);
217 $power = $smb->get_power(); # or $smb->cached_power();
218  
219 Get set output power (dBm);
220  
221 =head2 get_frq/set_frq
222  
223 $smb->set_frq(value => 1e6); # 1MHz
224 $frq = $smb->get_frq(); # or $smb->cached_frq();
225  
226 Get/Set output frequency (Hz).
227  
228 =head1 COPYRIGHT AND LICENSE
229  
230 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
231  
232 Copyright 2017 Andreas K. Huettel, Simon Reinhardt
233 2018 Simon Reinhardt
234 2020 Andreas K. Huettel
235  
236  
237 This is free software; you can redistribute it and/or modify it under
238 the same terms as the Perl 5 programming language system itself.
239  
240 =cut
« XPRESS/Sweep/Dummy.pm ↑ Summary Instrument/Multimeter.pm »