File Coverage

blib/lib/Lab/Moose/Instrument/SCPI/Sense/Function.pm
Criterion Covered Total %
statement 27 27 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 2 2 100.0
total 38 38 100.0


line stmt bran cond sub pod time code
1             package Lab::Moose::Instrument::SCPI::Sense::Function;
2             $Lab::Moose::Instrument::SCPI::Sense::Function::VERSION = '3.881';
3             #ABSTRACT: Role for the SCPI SENSe:FUNCtion subsystem
4              
5 4     4   2708 use v5.20;
  4         20  
6              
7 4     4   31 use Moose::Role;
  4         17  
  4         32  
8 4     4   21286 use Lab::Moose::Instrument::Cache;
  4         12  
  4         74  
9             use Lab::Moose::Instrument
10 4     4   2540 qw/validated_channel_getter validated_channel_setter/;
  4         13  
  4         253  
11 4     4   32 use MooseX::Params::Validate;
  4         11  
  4         32  
12 4     4   1954 use Carp;
  4         13  
  4         256  
13              
14 4     4   33 use namespace::autoclean;
  4         12  
  4         27  
15              
16             excludes 'Lab::Moose::Instrument::SCPI::Sense::Function::Concurrent';
17              
18              
19             # Cache used by multiple functions in sense subsystem
20             cache sense_function => ( getter => 'sense_function_query' );
21              
22             sub sense_function_query {
23 5     5 1 3289 my ( $self, $channel, %args ) = validated_channel_getter( \@_ );
24              
25 5         33 my $value = $self->query( command => "SENS${channel}:FUNC?", %args );
26 5         34 $value =~ s/["']//g;
27 5         25 return $self->cached_sense_function($value);
28             }
29              
30             sub sense_function {
31 9     9 1 30191 my ( $self, $channel, $value, %args ) = validated_channel_setter( \@_ );
32              
33 9         61 $self->write( command => "SENS${channel}:FUNC '$value'", %args );
34 9         47 return $self->cached_sense_function($value);
35             }
36              
37              
38              
39             1;
40              
41             __END__
42              
43             =pod
44              
45             =encoding UTF-8
46              
47             =head1 NAME
48              
49             Lab::Moose::Instrument::SCPI::Sense::Function - Role for the SCPI SENSe:FUNCtion subsystem
50              
51             =head1 VERSION
52              
53             version 3.881
54              
55             =head1 DESCRIPTION
56              
57             This role is intended for instruments which support a single sense function.
58             The command for setting the function must be SENS:FUNC $function.
59             Instruments with concurrent sense shell use the Sense::Function:Concurrent
60             role.
61              
62             The set sense function is used by other SENSE: roles, like SENSE:NPLC. For
63             example,
64              
65             $source->sense_function(value => 'CURR');
66             $source->sense_nplc(value => 10);
67              
68             will set the integration time for current measurement to 10 power line cycles.
69              
70             =head1 METHODS
71              
72             =head2 sense_function_query
73              
74             =head2 sense_function
75              
76             Query/Enable the sense function used by the instrument
77              
78             =head1 COPYRIGHT AND LICENSE
79              
80             This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
81              
82             Copyright 2016 Simon Reinhardt
83             2017 Andreas K. Huettel, Simon Reinhardt
84             2018 Simon Reinhardt
85             2020 Andreas K. Huettel
86              
87              
88             This is free software; you can redistribute it and/or modify it under
89             the same terms as the Perl 5 programming language system itself.
90              
91             =cut