Instrument/DummySource.pm

filter: Statementstmt 91.3% 53 / 58 Branchbran 100% 4 / 4 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 81.2% 13 / 16 Podpod 44.4% 4 / 9 totaltotal 75.4% 77 / 102 SCAR 18.1
CC
6
Cov
85%
new
4.0
get_range
2.0
set_range
2.0
CRAP 6.1
« Moose/Instrument/Lakeshore340/Helium3.pm ↑ Summary Moose/DataFile/Meta.pm »
1 package Lab::Instrument::DummySource;
2 #ABSTRACT: Dummy voltage source
3 3 $Lab::Instrument::DummySource::VERSION = '3.881';
4 3 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use parent 'Lab::Instrument::Source';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 our %fields = (
14 supported_connections => ['DEBUG'],
15  
16 connection_settings => {},
17  
18 device_settings => {
19  
20 # gate_protect => 1,
21 # gp_equal_level => 1e-5,
22 # gp_max_units_per_second => 0.002,
23 # gp_max_units_per_step => 0.001,
24 # gp_max_step_per_second => 2,
25  
26 max_sweep_time => 3600,
27 min_sweep_time => 0.1,
28 },
29  
30 device_cache => {
31 function => "Voltage",
32 range => 10,
33 level => 0,
34 output => undef,
35 },
36  
37 device_cache_order => [ 'function', 'range' ],
38 );
39  
40 sub new {
41 2 ▶ my $proto = shift;
Subroutine new: called CC=4 SCAR=13.9
Pod documented
42 2 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
43 2 my $self = $class->SUPER::new(@_);
44 2 $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__);
45  
46 2 print "DS: Created dummy instrument with config\n";
47 2 ▶ while ( my ( $k, $v ) = each %{ $self->device_settings() } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$self->device_settings;}) 34 2 36
48 34 ▶ $v = 'undef' if !defined($v);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 14 20 34
49 34 print "DS: $k -> $v\n";
50 }
51  
52 2 return $self;
53 }
54  
55 sub _device_init {
56 2 ▶ my $self = shift;
Subroutine _device_init: called CC=1 SCAR=0.0
57 2 return;
58 }
59  
60 # sub config_sweep {
61 # my $self = shift;
62 # my ($start, $target, $duration,$sections ,$tail) = $self->check_sweep_config(@_);
63  
64 # print "Dummy Source sweep configuration.\n";
65 # print "Duration: $duration\n";
66 # $self->{'sweeptime'} = $duration;
67 # }
68  
69 sub trg {
70 0 ▶ print "Dummy Source received trigger.\n";
Subroutine trg: not called CC=1 SCAR=6.9
Pod undocumented
71 }
72  
73 sub wait {
74 0 ▶ my $self = shift;
Subroutine wait: not called CC=1 SCAR=6.9
Pod undocumented
75 0 print "Dummy Source is sweeping.\n";
76 0 sleep( $self->{'sweeptime'} );
77 }
78  
79 sub _set_level {
80 11 ▶ my $self = shift;
Subroutine _set_level: called CC=1 SCAR=0.0
81 11 my ( $value, $tail ) = $self->_check_args( \@_, ['value'] );
82 11 say "DS: setting level to $value";
83 11 return $self->{'device_cache'}->{'level'} = $value;
84 }
85  
86 sub set_voltage {
87 11 ▶ my $self = shift;
Subroutine set_voltage: called CC=1 SCAR=0.0
Pod undocumented
88 11 my ( $voltage, $tail ) = $self->_check_args( \@_, ['voltage'] );
89 11 return $self->set_level( $voltage, $tail );
90 }
91  
92 sub get_level {
93 27 ▶ my $self = shift;
Subroutine get_level: called CC=1 SCAR=0.0
Pod documented
94  
95 27 return $self->{'device_cache'}->{'level'};
96 }
97  
98 sub active {
99 0 ▶ return 0;
Subroutine active: not called CC=1 SCAR=6.9
Pod undocumented
100 }
101  
102 sub abort {
103 2 ▶ return 0;
Subroutine abort: called CC=1 SCAR=0.0
Pod undocumented
104 }
105  
106 sub set_range {
107 1 ▶ my $self = shift;
Subroutine set_range: called CC=2 SCAR=7.1
Pod documented
108 1 my $range = shift;
109 1 my $args = {@_};
110 1 ▶ my $channel = $args->{'channel'} || $self->default_channel();
Condition33%1/3
$args->{'channel'} || $self->default_channel
l!l&&r!l&&!r
010
MC/DC0%0/2
$args->{'channel'} || $self->default_channel
$args->{'channel'} $self->default_channel
Truth table33%1/3
A || B
A= $args->{'channel'}B= $self->default_channel
ABresult
1X1
011
000
111  
112 1 my $tmp = "last_range_$channel";
113 1 $self->{$tmp} = $range;
114 1 print "DS: setting virtual range of channel $channel to $range\n";
115 }
116  
117 sub get_range {
118 2 ▶ my $self = shift;
Subroutine get_range: called CC=2 SCAR=7.1
Pod documented
119 2 my $args = {@_};
120 2 ▶ my $channel = $args->{'channel'} || $self->default_channel();
Condition33%1/3
$args->{'channel'} || $self->default_channel
l!l&&r!l&&!r
020
MC/DC0%0/2
$args->{'channel'} || $self->default_channel
$args->{'channel'} $self->default_channel
Truth table33%1/3
A || B
A= $args->{'channel'}B= $self->default_channel
ABresult
1X1
011
000
121  
122 2 my $tmp = "last_range_$channel";
123 2 print "DS: getting virtual range: $$self{$tmp}\n";
124 2 return $self->{$tmp};
125 }
126  
127 3 1;
128  
129 __END__
130  
131 =pod
132  
133 =encoding utf-8
134  
135 =head1 NAME
136  
137 Lab::Instrument::DummySource - Dummy voltage source
138  
139 =head1 VERSION
140  
141 version 3.881
142  
143 =head1 DESCRIPTION
144  
145 The Lab::Instrument::DummySource class implements a dummy voltage source
146 that does nothing but can be used for testing purposes.
147  
148 Only developers will ever make use of this class.
149  
150 =head1 SEE ALSO
151  
152 =over 4
153  
154 =item (L<Lab::Instrument::Source>).
155  
156 =back
157  
158 =head1 COPYRIGHT AND LICENSE
159  
160 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
161  
162 Copyright 2011 Andreas K. Huettel, Florian Olbrich
163 2012 Alois Dirnaichner
164 2015 Alois Dirnaichner
165 2016 Simon Reinhardt
166 2017 Andreas K. Huettel
167 2020 Andreas K. Huettel
168  
169  
170 This is free software; you can redistribute it and/or modify it under
171 the same terms as the Perl 5 programming language system itself.
172  
173 =cut
« Moose/Instrument/Lakeshore340/Helium3.pm ↑ Summary Moose/DataFile/Meta.pm »