File Coverage

blib/lib/Lab/Instrument/Cryogenic_SMS.pm
Criterion Covered Total %
statement 8 108 7.4
branch 0 12 0.0
condition 0 3 0.0
subroutine 3 11 27.2
pod 1 8 12.5
total 12 142 8.4


line stmt bran cond sub pod time code
1             package Lab::Instrument::Cryogenic_SMS;
2             #ABSTRACT: Cryogenic SMS magnet power supply
3             $Lab::Instrument::Cryogenic_SMS::VERSION = '3.880';
4 1     1   1693 use v5.20;
  1         3  
5              
6 1     1   5 use strict;
  1         2  
  1         21  
7 1     1   5 use Lab::Instrument;
  1         2  
  1         1275  
8              
9             our @ISA = ('Lab::Instrument');
10              
11             # does not use any magnet supply specific code yet
12              
13             our %fields = (
14             supported_connections => [ 'GPIB', 'VISA' ],
15              
16             # default settings for the supported connections
17             connection_settings => {
18             gpib_board => 0,
19             gpib_address => undef,
20             },
21              
22             # device_settings => {
23             # use_persistentmode => 0,
24             # can_reverse => 0,
25             # can_use_negative_current => 0,
26             # },
27             );
28              
29             sub new {
30 0     0 1   my $proto = shift;
31 0   0       my $class = ref($proto) || $proto;
32 0           my $self = $class->SUPER::new(@_);
33 0           $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__);
  0            
34 0           print "Cryogenic SMS magnet supply code is experimental.\n";
35 0           return $self;
36             }
37              
38             sub ramp_to_mid {
39 0     0 0   my $self = shift;
40 0           $self->write("RAMP MID\n");
41 0           my $status = $self->status();
42 0           while ( $status =~ /HOLDING/ )
43             { # takes care that command is finally executed
44 0           $status = $self->status();
45              
46 0           $status =~ /MID SETTING: (.*) AMPS/;
47 0           my $mid = $1;
48 0           $status =~ /OUTPUT: (.*) AMPS/;
49 0           my $out = $1;
50              
51 0 0         last if $mid == $out; # breaks if we have already reached target
52              
53 0           $self->write("RAMP MID\n");
54 0           print "power supply not responding, send command again\n";
55 0           sleep(1);
56             }
57              
58 0           while ( $status =~ /RAMPING/ ) {
59 0           $status = $self->status();
60 0           sleep(1);
61             }
62              
63 0           $status =~ /MID SETTING: (.*) AMPS/;
64 0           my $mid = $1;
65 0           $status =~ /OUTPUT: (.*) AMPS/;
66 0           my $out = $1;
67              
68 0 0         return 0 if $mid == $out;
69 0           return 1;
70             }
71              
72             sub ramp_to_zero {
73 0     0 0   my $self = shift;
74 0           $self->write("RAMP ZERO\n");
75 0           my $status = $self->status();
76 0           while ( $status =~ /HOLDING/ )
77             { # takes care that command is finally executed
78 0           $status = $self->status();
79              
80 0           $status =~ /OUTPUT: (.*) AMPS/;
81 0           my $out = $1;
82              
83 0 0         last if $out == 0; # breaks if we have already reached target
84              
85 0           $self->write("RAMP ZERO\n");
86 0           print "power supply not responding, send command again\n";
87 0           sleep(1);
88             }
89              
90 0           while ( $status =~ /RAMPING/ ) {
91 0           $status = $self->status();
92 0           sleep(1);
93             }
94              
95 0           $status = $self->status();
96 0           $status =~ /OUTPUT: (.*) AMPS/;
97 0           my $out = $1;
98 0 0         if ( $out == 0 ) {
99 0           return 0;
100             }
101 0           return 1;
102             }
103              
104             sub ramp_to_max {
105 0     0 0   my $self = shift;
106 0           $self->write("RAMP MAX\n");
107 0           my $status = $self->status();
108 0           while ( $status =~ /HOLDING/ )
109             { # takes care that command is finally executed
110 0           $status = $self->status();
111              
112 0           $status =~ /MAX SETTING: (.*) AMPS/;
113 0           my $max = $1;
114 0           $status =~ /OUTPUT: (.*) AMPS/;
115 0           my $out = $1;
116              
117 0 0         last if $max == $out; # breaks if we have already reached target
118              
119 0           $self->write("RAMP MID\n");
120 0           print "power supply not responding, send command again\n";
121 0           sleep(1);
122             }
123              
124 0           while ( $status =~ /RAMPING/ ) {
125 0           $status = $self->status();
126 0           sleep(1);
127             }
128              
129 0           $status =~ /MAX SETTING: (.*) AMPS/;
130 0           my $max = $1;
131 0           $status =~ /OUTPUT: (.*) AMPS/;
132 0           my $out = $1;
133              
134 0 0         return 0 if $max == $out;
135 0           return 1;
136             }
137              
138             sub heater_on {
139 0     0 0   my $self = shift;
140 0           $self->write("HEATER ON\n");
141              
142 0           my $status = $self->status();
143 0           while ( $status =~ /HEATER STATUS: OFF/ )
144             { # takes care that command is finally executed
145 0           sleep(1);
146 0           $self->write("HEATER ON\n");
147 0           print "power supply not responding, send command again\n";
148 0           sleep(1);
149 0           $status = $self->status();
150             }
151 0           sleep(10);
152 0           return 0;
153             }
154              
155             sub heater_off {
156 0     0 0   my $self = shift;
157 0           $self->write("HEATER OFF\n");
158              
159 0           my $status = $self->status();
160 0           while ( $status =~ /HEATER STATUS: ON/ )
161             { # takes care that command is finally executed
162 0           sleep(1);
163 0           print "power supply not responding, send command again\n";
164 0           $self->write("HEATER OFF\n");
165 0           sleep(1);
166 0           $status = $self->status();
167             }
168 0           sleep(10);
169 0           return 0;
170             }
171              
172             sub status {
173 0     0 0   my $self = shift;
174 0           my $result = $self->query( command => "U\n", read_length => 1000 );
175 0           for ( my $i = 1; $i <= 20; $i++ ) {
176 0           $result .= $self->query( command => "U\n", read_length => 1000 );
177              
178             }
179 0           return $result;
180             }
181              
182             sub read_messages {
183 0     0 0   my $self = shift;
184 0           my $result = $self->read( read_length => 1000 );
185             }
186              
187             1;
188              
189             __END__
190              
191             =pod
192              
193             =encoding UTF-8
194              
195             =head1 NAME
196              
197             Lab::Instrument::Cryogenic_SMS - Cryogenic SMS magnet power supply
198              
199             =head1 VERSION
200              
201             version 3.880
202              
203             =head1 COPYRIGHT AND LICENSE
204              
205             This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
206              
207             Copyright 2013 Andreas K. Huettel
208             2016 Simon Reinhardt
209             2017 Andreas K. Huettel
210             2020 Andreas K. Huettel
211              
212              
213             This is free software; you can redistribute it and/or modify it under
214             the same terms as the Perl 5 programming language system itself.
215              
216             =cut