Moose/Instrument/SCPI/Sense/Function/Concurrent.pm

filter: Statementstmt 89.2% 58 / 65 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 86.6% 13 / 15 Podpod 100% 8 / 8 totaltotal 89.1% 82 / 92 CC 3 SCAR 3.9
CC
3
Cov
88%
sense_function_on
3.0
sense_function_query
2.0
sense_function_off_query
2.0
CRAP 1.5
« Moose/Instrument/HP83732A.pm ↑ Summary Moose/Instrument/Zhinst.pm »
1 package Lab::Moose::Instrument::SCPI::Sense::Function::Concurrent;
2 3 $Lab::Moose::Instrument::SCPI::Sense::Function::Concurrent::VERSION = '3.931';
3 #ABSTRACT: Role for the SCPI SENSe:FUNCtion subsystem with support for concurrent sense
4  
5 3 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Lab::Moose::Instrument::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 use Lab::Moose::Instrument
10 3 ▶ qw/validated_channel_getter validated_channel_setter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 3 excludes 'Lab::Moose::Instrument::SCPI::Sense::Function';
17  
18  
19 3 cache sense_function_concurrent =>
20 ( getter => 'sense_function_concurrent_query' );
21  
22 2 ▶sub sense_function_concurrent_query {
Subroutine sense_function_concurrent_query: called CC=1 SCAR=0.0
Pod documented
23 2 my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
24  
25 2 my $value = $self->query( command => "SENS${channel}:FUNC:CONC?", %args );
26 2 return $self->cached_sense_function_concurrent($value);
27 }
28  
29 4 ▶sub sense_function_concurrent {
Subroutine sense_function_concurrent: called CC=1 SCAR=0.0
Pod documented
30 4 my ( $self, $channel, $value, %args ) = validated_channel_setter(
31 \@_,
32 value => { isa => 'Bool' }
33 );
34  
35 4 $self->write( command => "SENS${channel}:FUNC:CONC $value", %args );
36 4 return $self->cached_sense_function_concurrent($value);
37 }
38  
39  
40 3 cache sense_function => ( getter => 'sense_function_query' );
41  
42 2 ▶sub sense_function {
Subroutine sense_function: called CC=1 SCAR=0.0
Pod documented
43 2 my ( $self, $channel, $value, %args ) = validated_channel_setter( \@_ );
44 2 return $self->cached_sense_function($value);
45 }
46  
47  
48 0 ▶sub sense_function_query {
Subroutine sense_function_query: not called CC=1 SCAR=6.9
Pod documented
49  
50 # overwrite in instrument driver to get different default.
51 0 return 'CURR';
52 }
53  
54  
55 3 cache sense_function_on =>
56 ( isa => 'ArrayRef[Str]', getter => 'sense_function_on_query' );
57  
58 6 ▶sub sense_function_on {
Subroutine sense_function_on: called CC=3 SCAR=11.1
Pod documented
59 6 my ( $self, $channel, $value, %args ) = validated_channel_setter(
60 \@_,
61 value => { isa => 'ArrayRef[Str]' }
62 );
63 6 my @values = @{$value};
64 6 ▶ if ( not $self->cached_sense_function_concurrent ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->cached_sense_function_concurrent) 3 3 6
65 3 ▶ if ( @values != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@values != 1) 0 3 3
66 0 croak
67 "sense_function_on without concurrent sense only accepts single function";
68 }
69 }
70 6 @values = map {"'$_'"} @values;
71 6 my $param = join( ',', @values );
72  
73 6 $self->write( command => "SENS${channel}:FUNC:ON $param", %args );
74 6 return $self->sense_function_on_query(%args);
75 }
76  
77 13 ▶sub sense_function_on_query {
Subroutine sense_function_on_query: called CC=1 SCAR=0.0
Pod documented
78 13 my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
79  
80 13 my $value = $self->query( command => "SENS${channel}:FUNC:ON?", %args );
81 13 $value =~ s/["']//g;
82 13 my @values = split( ',', $value );
83 13 $self->cached_sense_function_on( [@values] );
84 13 return [@values];
85 }
86  
87  
88 2 ▶sub sense_function_off {
Subroutine sense_function_off: called CC=1 SCAR=0.0
Pod documented
89 2 my ( $self, $channel, $value, %args ) = validated_channel_setter(
90 \@_,
91 value => { isa => 'ArrayRef[Str]' }
92 );
93 2 my @values = @{$value};
94 2 @values = map {"'$_'"} @values;
95 2 my $param = join( ',', @values );
96  
97 2 $self->write( command => "SENS${channel}:FUNC:OFF $param", %args );
98  
99 # update cached_sense_function_on
100 2 $self->sense_function_on_query(%args);
101 }
102  
103 0 ▶sub sense_function_off_query {
Subroutine sense_function_off_query: not called CC=1 SCAR=6.9
Pod documented
104 0 my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
105  
106 0 my $value = $self->query( command => "SENS${channel}:FUNC:OFF?", %args );
107 0 $value =~ s/["']//g;
108 0 my @values = split( ',', $value );
109 0 return [@values];
110 }
111  
112 3 1;
113  
114 __END__
« Moose/Instrument/HP83732A.pm ↑ Summary Moose/Instrument/Zhinst.pm »