File Coverage

blib/lib/Lab/Instrument/Dummysource.pm
Criterion Covered Total %
statement 37 43 86.0
branch n/a
condition 1 3 33.3
subroutine 6 7 85.7
pod 0 3 0.0
total 44 56 78.5


line stmt bran cond sub pod time code
1             #$Id: Dummysource.pm 613 2010-04-14 20:40:41Z schroeer $
2            
3             package Lab::Instrument::Dummysource;
4 1     1   28574 use strict;
  1         3  
  1         34  
5 1     1   580 use Lab::Instrument::Source;
  1         3  
  1         649  
6            
7             our $VERSION = sprintf("0.%04d", q$Revision: 613 $ =~ / (\d+) /);
8            
9             our @ISA=('Lab::Instrument::Source');
10             our $maxchannels=16;
11            
12             my $default_config={
13             gate_protect => 1,
14             gp_max_volt_per_second => 0.002,
15             gp_max_volt_per_step => 0.001,
16             gp_max_step_per_second => 2,
17             gp_min_volt => -1,
18             gp_max_volt => 1,
19             gp_equal_level => 0.000001,
20             };
21            
22             sub new {
23 1     1 0 16 my $proto = shift;
24 1         3 my @args=@_;
25 1   33     9 my $class = ref($proto) || $proto;
26 1         14 my $self = $class->SUPER::new($default_config,@args);
27 1         3 bless ($self, $class);
28 1         49 print "DS: Created dummy instrument with config\n";
29 1         3 while (my ($k,$v)=each %{$self->configure()}) {
  8         24  
30 7         61 print "DS: $k -> $v\n";
31             }
32 1         32 for (my $i=1; $i<=$maxchannels; $i++) {
33 16         26 my $tmp="last_volt_$i";
34 16         130 $self->{$tmp}=0;
35 16         27 my $tmp="last_range_$i";
36 16         51 $self->{$tmp}=1;
37             }
38 1         9 return $self
39             }
40            
41             sub _set_voltage {
42 1218     1218   1771 my $self=shift;
43 1218         1418 my $voltage=shift;
44 1218         1489 my $channel=shift;
45 1218         1853 my $tmp="last_volt_$channel";
46 1218         2008 $self->{$tmp}=$voltage;
47 1218         14123 print "DS: _setting virtual voltage $channel to $voltage\n";
48             }
49            
50             sub _get_voltage {
51 8     8   11 my $self=shift;
52 8         12 my $channel=shift;
53 8         20 my $tmp="last_volt_$channel";
54 8         61 print "DS: _getting virtual voltage $channel: $$self{$tmp}\n";
55 8         31 return $self->{$tmp};
56             }
57            
58             sub set_range {
59 0     0 0 0 my $self=shift;
60 0         0 my $range=shift;
61 0         0 my $channel=shift;
62 0         0 my $tmp="last_range_$channel";
63 0         0 $self->{$tmp}=$range;
64 0         0 print "DS: setting virtual range of channel $channel to $range\n";
65             }
66            
67             sub get_range {
68 1     1 0 3 my $self=shift;
69 1         2 my $channel=shift;
70 1         3 my $tmp="last_range_$channel";
71 1         6 print "DS: getting virtual range: $$self{$tmp}\n";
72 1         5 return $self->{$tmp};
73             }
74            
75             1;
76            
77             =head1 NAME
78            
79             Lab::Instrument::Dummysource - Dummy voltage source
80            
81             =head1 DESCRIPTION
82            
83             The Lab::Instrument::Dummysource class implements a dummy voltage source
84             that does nothing but fullfill testing purposes.
85            
86             Only developers will ever make use of this class.
87            
88             =head1 SEE ALSO
89            
90             =over 4
91            
92             =item (L).
93            
94             =back
95            
96             =head1 AUTHOR/COPYRIGHT
97            
98             This is $Id: Dummysource.pm 613 2010-04-14 20:40:41Z schroeer $
99            
100             Copyright 2005-2006 Daniel Schröer (L)
101            
102             This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
103            
104             =cut